gicinc

Update Cursor error in file geodatabase: RuntimeError: An expected Field...

Discussion created by gicinc on Aug 1, 2013
Latest reply on Aug 1, 2013 by gicinc
I'm trying to replace <NULL> values in a number of fields for a shapefile in a file geodatabase. The hope is that once I do this, field calculator will be friendlier in the model I'm building. Below is the part of the script that is giving me trouble and the error. I repeat this section for each field. I've based my code on a tutorial from Paul Zandbergen's Python Scripting for ArcGIS book (I'm new to python) and have scoured forums for solutions with no luck. The line the error references is the "for row in cursor:" line. All lines before this section are just import, workspace and # lines.

#Update ElevSTD to replace NULL with 0.
delimElev = arcpy.AddFieldDelimiters(fc, ["ElevSTD"])
cursor = arcpy.da.UpdateCursor(fc, ["ElevSTD"], delimElev + ' = None')
for row in cursor:
    row[0] = 0
    cursor.updateRow(row)
del row
del cursor

Traceback (most recent call last):
  File "C:\Python27\ArcGIS10.1\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\Arkansas GIS Appendix\ReplaceNulls.py", line 14, in <module>
    for row in cursor:
RuntimeError: An expected Field was not found or could not be retrieved properly. [Cores_SpJnSoilsVar]



Thanks for any help or insight you can provide!

Outcomes