Solved! Go to Solution.
import arcpy import os # replace data path with your OWN data. in_data = r"C:\data\f.gdb\parcels" field_list = [] numeric_fields = ["Double", "Integer", "SmallInteger"] fields = arcpy.ListFields(in_data) for field in fields: if (field.type in numeric_fields): field_list.append(field.name) # convert the list of fields to a semicolor delimited string fields = ";".join(field_list) rows = arcpy.UpdateCursor(in_data, '', '', fields) count = len(field_list) for row in rows: for k in range(count): if row.isNull(field_list): row.setValue(field_list , 0) rows.updateRow(row)
import arcpy import os # replace data path with your OWN data. in_data = r"C:\data\f.gdb\parcels" field_list = [] numeric_fields = ["Double", "Integer", "SmallInteger"] fields = arcpy.ListFields(in_data) for field in fields: if (field.type in numeric_fields): field_list.append(field.name) # convert the list of fields to a semicolor delimited string fields = ";".join(field_list) rows = arcpy.UpdateCursor(in_data, '', '', fields) count = len(field_list) for row in rows: for k in range(count): if row.isNull(field_list): row.setValue(field_list , 0) rows.updateRow(row)
You can do it ModelBuilder but in a cumbersome way. You will need to embed two extra models and a script tool in a main model. Instead, use this script - simple and straightforward.import arcpy import os # replace data path with your OWN data. in_data = r"C:\data\f.gdb\parcels" field_list = [] numeric_fields = ["Double", "Integer", "SmallInteger"] fields = arcpy.ListFields(in_data) for field in fields: if (field.type in numeric_fields): field_list.append(field.name) # convert the list of fields to a semicolor delimited string fields = ";".join(field_list) rows = arcpy.UpdateCursor(in_data, '', '', fields) count = len(field_list) for row in rows: for k in range(count): if row.isNull(field_list): row.setValue(field_list , 0) rows.updateRow(row)
Let me know if you have any trouble.
If you want you can modify the script a little bit to use it in a script tool.