I am trying to use the UpdateCursor function to run through each field in each row and to compile a string which is then added to the AbvField. I'm trying to do this in the python window, rather than as a standalone script.
I get the error: Runtime error : Row: Field updateRow does not exist
I have included all the code except for the subs dict, which is simply a dictionary of species names (keys) and abbreviations (values) with which the script creates the string for the AbvField. Everything works fine except for the updating the field.
TheShapefile="Primary_biodiversity_layer"
AbvField = "Sp1"
Rows=arcpy.UpdateCursor(TheShapefile)
Fields = arcpy.ListFields(TheShapefile)
SpList = []
newDict = {}
for TheRow in Rows:
RString = ""
for TheField in Fields:
TheFieldName=TheField.name
TheValue=TheRow.getValue(TheFieldName)
if TheValue == "":
pass
elif TheValue not in subs.keys():
pass
else:
RString += subs[TheValue] + ", "
if TheValue not in newDict.keys():
newDict[TheValue] = subs[TheValue]
else:
pass
TheRow.setValue(AbvField, RString)
TheRow.updateRow(TheRow)
del TheRow
1 Answer 1
The indentation in your code snippet looks a little astray but I think what is giving you the error you reported is that you have:
TheRow.updateRow(TheRow)
when it should be:
Rows.updateRow(TheRow)