2

I have been trying to get Update Cursor to update a field in my attribute tale.

import arcpy
fields = ['STATE_ABBR','Last_Update']
fc = "C:\Users\sword\Desktop\GIS Web Course\PersonalProject\GIS_Project.gdb\USAStates"
with arcpy.da.UpdateCursor(fc, fields) as cursor:
    for row in cursor:
        if row[0] == 'HI':
            row[1] = '1'
        cursor.updateRow(row)

One Row has state abbreviations and the row Last_Update is blank, I just want to place a one in that row. I enter it in the Python box in ArcGis, it throw no errors but simply does nothing. The row doesn't update. The Last_Update column is a string field, and I have verified the path name in fc. What am I doing wrong? This is almost a copy from ESRI webite of the format.

1
  • 1
    Could it be as simple as refreshing your attribute table? Perhaps, remove the feature class from the table of contents and then add it again and pull up the attribute table. – Aaron Jul 9 '16 at 4:43
2

You need to refresh the attribute table by removing the feature class from the table of contents and then add it again and pull up the attribute table.

Alternatively, close your view of the attribute table and open it again.

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.