Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

Updating field in feature class using ArcPy cursor?

$
0
0

I want to update a field in my feature class. I tried to use a da.SearchCursor (code below) but was quickly reminded that tuples are immutable… I ran the code but it failed with a TypeError: 'tuple' object does not support item assignment.

How do I most efficiently retrieve all rows from a feature class and update a field of each row and save it back to the feature class?

with arcpy.da.SearchCursor(fc, fldNames) as sc:
    for thing in sc:
        tmp = 0

        #
        # do stuff here
        #

        thing[idxField] = tmp

Viewing all articles
Browse latest Browse all 767

Trending Articles