Pre-Logic Script Code: def nullToBlank(fieldValue): if fieldValue == None: return ' ' # returns a string with just a space in it (looks blank). else: return fieldValue Expression: nullToBlank(!oldField!)
By 'blank' you mean...? It also depends on the data type of your field. The easy way: if your field is a string you can do the following in a field calculator (to be safe: create a new field, then use this to get the values into it, then delete the old field; but you can just have the field calculate on itself): Pre-Logic Script Code: def nullToBlank(fieldValue): if fieldValue == None: return ' ' # returns a string with just a space in it (looks blank). else: return fieldValue Expression: nullToBlank(!oldField!) The hard way would be to make a Python script that iterates through all the rows (using UpdateCursor) and replaces the values that are == None with something...
#One way... txtFieldList = arcpy.ListFields(myFC, "", "STRING") updateRows = arcpy.UpdateCursor(myFC) for updateRow in updateRows: for txtField in txtFieldList: if updateRow.isNull(txtField.name): updateRow.setValue(txtField.name, '') updateRows.updateRow(updateRow) del updateRow, updateRows
#Another way that might? be faster/better: txtFieldList = arcpy.ListFields(myFC, "", "STRING") for txtField in txtFieldList: updateRows = arcpy.UpdateCursor(myFC, txtField.name + " IS NULL", "", txtField.name) for updateRow in updateRows: updateRow.setValue(txtField.name, '') updateRows.updateRow(updateRow) del updateRow, updateRows
Didn't test it, but this code should "blank-ify" any NULL text fields: #One way... txtFieldList = arcpy.ListFields(myFC, "", "STRING") updateRows = arcpy.UpdateCursor(myFC) for updateRow in updateRows: for txtField in txtFieldList: if updateRow.isNull(txtField.name): updateRow.setValue(txtField.name, '') updateRows.updateRow(updateRow) del updateRow, updateRows#Another way that might? be faster/better: txtFieldList = arcpy.ListFields(myFC, "", "STRING") for txtField in txtFieldList: updateRows = arcpy.UpdateCursor(myFC, txtField.name + " IS NULL", "", txtField.name) for updateRow in updateRows: updateRow.setValue(txtField.name, '') updateRows.updateRow(updateRow) del updateRow, updateRows
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.