0

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
2

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.