I am trying to replace a <Null> value in a selected field. When I do a find and replace I get an error that no fields have been detected. I have put in to find <Null> and replace it with the info that I want. I have selected the field but I still get this error. Can anyone help me with this? Is there a better or another way to do this? It just takes too long to select each field and type in the replacement info.
Hi,one Quick answer is for you is that convert feature class into shape file,Shapefile's do not support Null entries and automatically convert Null to zero.You didn't mention that where you want to change the <Null> Values and what you want to replace with. Ok this time i assume that you want to replace <Null> values with some "x" value then try this script simple and straightforward. you just replace 0 to your value and make sure that you put a right path for "in_data"import arcpy
import os
# replace data path with your OWN data.
in_data = r"C:\Data\Sample.mdb\NullValues"
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 face any issues...Gud Luck...!!