I have 100 shape files from different sub folders. I want to check "Population" field in each shape file. If the "Population" field in any of the shape file is ["", " ", None] then print me the name of those particular shape files.
import os
import fnmatch
import arcpy
rootPath = r"C:\Project\layers"
pattern = 'mig*.shp'
for root, dirs, files in os.walk(rootPath):
for filename in fnmatch.filter(files, pattern):
shp = os.path.join(root, filename)
if arcpy.ListFields(shp, "Population"):
print("{} has Population field".format(shp))
with arcpy.da.SearchCursor(shp, ["Population"]) as rows:
for row in rows:
if row[0] == ["", " ", None]:
print("{} has a empty value".format(shp))
else:
print "OK"
the script working fine to find shape files name those are having population field. But its not working to find shape name which are having empty population field.
I am getting "runtime error". TypeError: String indices must be integers, not str.