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.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jul 9, 2016 at 4:20
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. Commented Jul 9, 2016 at 4:43

1 Answer 1

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.

answered Jul 9, 2016 at 4:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.