I am trying to print empty/blank or Null records with the following but when nothing is printed and there is empty/blank and Null records in the layer. I would also like to print the number of empty/blank or Null records.
fc = "C:/Temp/Test.gdb/feature Class"
fields = ["OBJECTID", "PN1"]
for field in fields:
where = field + " IS " " OR NULL"
try:
with arcpy.da.SearchCursor(fc, fields, where) as cursor:
for row in cursor:
print("OBJECTID {0}").format(row[0]) + " has a Empty/ Blank or NULL value in field " + field
except RuntimeError:
pass
del cursor
counter = 0
with arcpy.da.SearchCursor(fc,["OBJECTID","PN1"]) as cursor:
for row in cursor:
if row[1] in ["", " ", None]:
counter += 1
print('{} {} is null {} times'.format(row[0],row[1],counter))
else:
pass