Я думаю, что сначала нужно быстрее проверить с помощью запроса sql, если в какой-либо строке есть значения None, прежде чем читать каждую строку с помощью курсора (кстати, используйте курсоры доступа к данным (da.SearchCursor), они намного быстрее) ,
Попробуйте:
import arcpy, os
arcpy.env.overwriteOutput = True #To be able to use same layer name in MakeFeatureLayer
shapefolder = r'C:\GIS\data\testdata'
for path, subdirs, files in os.walk(shapefolder):
for name in files:
if name.endswith('.shp'):
shapefile = os.path.join(path,name)
fields_to_check = [f.name for f in arcpy.ListFields(shapefile) if not f.required]
sql = ' OR '.join([field+" IS NULL" for field in fields_to_check]) #Construct sql query like: 'Field1 IS NULL OR Field2 IS NULL OR ...'
arcpy.MakeFeatureLayer_management(in_features=shapefile, out_layer='layer', where_clause=sql) #Use the sql clause to create a temporary layer
shapefile_row_count = int(arcpy.GetCount_management(in_rows=shapefile).getOutput(0))
if int(arcpy.GetCount_management(in_rows='layer').getOutput(0)) >= shapefile_row_count and shapefile_row_count >0: #Check if row number returned by query are >= to shapefile row count
nonefields = []
with arcpy.da.SearchCursor('layer', fields_to_check) as cursor:
for row in cursor:
if None in row:
nones = [fields_to_check[j] for j in [i for i in range(len(row)) if row[i] is None]]
nonefields.extend(nones)
nonefields = ', '.join(sorted(list(set(nonefields))))
print 'None value(s) in shapefile: {}, field(s): {}'.format(shapefile, nonefields)
Должно вывести что-то вроде:
None value(s) in shapefile: C:\GIS\data\testdata\intertest.shp, field(s): fieldname1, fieldname2, fieldname10
None value(s) in shapefile: C:\GIS\data\testdata\polygons.shp, field(s): blabla, blablabla