2

I have a list of values of buildings total height and want to update the corresponding field in the shapefile.

fclass is my shapefile totalh is the field which i want to update totaheight is a list with height values for each building in the shapefile (same order)

This is what I am trying:

i = 0

with arcpy.da.UpdateCursor(fclass,"totalh") as updatecursor:

    for row in updatecursor:

        row[i] = total_height[i]
        updatecursor.UpdateRow(row)
        i = i+1

The error:

Traceback (most recent call last):
  File "C:/wspace2/bheights.py", line 45, in <module>
    updatecursor.UpdateRow(row)
AttributeError: 'da.UpdateCursor' object has no attribute 'UpdateRow'
  • 1
    row[n] refers to column 'n' in the row, so you're about to have a problem once you fix the capitalization. – Vince Jun 2 '16 at 18:52
8

Change

updatecursor.UpdateRow(row) 

to

updatecursor.updateRow(row)

The U is lowercase.

http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/updatecursor-class.htm

Also, check the following statement:

row[i] = total_height[i]

this should probably be

row[0] = total_height[i]

since you want to reference and update the first attribute in the shape file

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.