Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Essentially I am trying to calculate a value for a couple of fields after adding them. Below you can see how I am adding the fields and then an example on how my "for" statement is looping through the cursors to add values.

I keep getting an error: "TypeError: sequence size must match size of the row"

I'm not sure what to do about this. Is there a better method than to use the UpdateCursor updateRow statements?

fieldName = ["azVEqSet", "azVERis"]
try:
    arcpy.AddField_management(points, fieldName[0] ,"FLOAT")
    arcpy.AddField_management(points, fieldName[1] ,"FLOAT")
except:
    arcpy.DeleteField_management(points, [fieldName[0], fieldName[1]])
    arcpy.AddField_management(points, fieldName[0] ,"FLOAT")
    arcpy.AddField_management(points, fieldName[1] ,"FLOAT")

cursor = arcpy.da.UpdateCursor(points, ["azVEqSet", "azVERis", "POINT_X", "RASTERVALU", "POINT_Y"])
for row in cursor:
...
     numberInsert = ReturnedVariable
     row[0] = numberInsert
     cursor.updateRow([row])
share|improve this question

1 Answer 1

up vote 7 down vote accepted

Change:

cursor.updateRow([row])

To:

cursor.updateRow(row)

Explanation:

  • row, which you obtained from the arcpy.da.UpdateCursor is a sequence (a tuple, specifically) of a certain length expected by the updateRow method, and by wrapping row in brackets, you are creating a new sequence (a list, specifically) of length 1, which is not the length expected.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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