I am trying to use the search cursor to find all null values within a table but am having a hard time with the where-clause statement. How do i search for null values using searchcursor?
Your where expression is poorly formed, and you missed a step in the arcpy.da.walk.I would suggest avoiding the cursor altogether:
fields = ["A", "B", "C", "D", "E", "F", "G"]
where = ['"{0}" IS NULL'.format(f) for f in fields]
where = " OR ".join(where)
# where = "A" IS NULL OR "B" IS NULL OR ...
for dirpath, dirnames, filenames in arcpy.da.Walk(in_workspace, datatype="featureclass", type="Polyline"):
for filename in filenames:
path = os.path.join(dirpath, filename) # see example 2 in the help for arcpy.da.walk
lyr = arcpy.MakeFeatureLayer_management(path, "lyr", where)
rows = int(arcpy.GetCount_management(lyr).getOutput(0))
if rows > 0: print filename, " has null values"
If you want to look at all fields no matter what they are named, you can try this inside the loop:
fields = [f.name for f in arcpy.Describe(path).Fields]
where = " OR ".join(['"{0}" IS NULL'.format(f) for f in fields])
lyr = arcpy.MakeFeatureLayer_management(path, "lyr", where)