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 Answer 1
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
row[n]
refers to column 'n' in the row, so you're about to have a problem once you fix the capitalization.