Hello,
I want to delete all empty fields in a feature class (arcgis pro 3.0 - notebooks) - with no sucess. The following script doesn't work, it prints fields as count = 0 which have valid attributes.
Any better ideas?
fc = "Merge_1"
fields = [f.name for f in arcpy.ListFields(fc) if not f.required]
for field in fields:
count = 0
with arcpy.da.SearchCursor(fc, field) as cursor:
for row in cursor:
if row[0] is None or row[0] in ["", " ", "0"]:
count += 0
else:
count += 1
break
print(field, count)
Solved! Go to Solution.
That is a problem. People should really set up Excel's "Data Validation" for their spreadsheet columns if they are using Excel for data entry or acquisition.
Sorry it works sucessfully ...
since you have run it against something to compare to, what does this return
Field Statistics To Table (Data Management)—ArcGIS Pro | Documentation
wondering what is returned if All types and the options for nulls, count and unique
Didn't knowed this tool, if I run it with one empty field I want to delete I get something like this:
Sorry it's in german ...
I think the problem with this tool will be that it's some kind of chaotic data merge out of excel files in the fc. The fields to delete could contain Null values, "", "0", " " ... .
That is a problem. People should really set up Excel's "Data Validation" for their spreadsheet columns if they are using Excel for data entry or acquisition.