If IsNull() Then ' Substitute with your real field name here Output = 0 ' Specify the replacement value for Null here. Make sure it is valid for the field you are calculating. Else Output = ' Substitute with your real field name here End If
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.
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)
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.