ArcPy Update Cursor vs. Calculate Field Geoprocessing Tool

4555
2
11-16-2011 09:23 AM
GeorgeNewbury
Occasional Contributor
Thought I'd share my experience with topic.

I'm reading a CSV file, making a feature layer from it, and performing transformations on the geometry.  In the end I'm updating the feature class's fields with the geometry, e.g. Point.X, .Y, and .Z going into 'Easting', 'Northing', and 'Altitude' fields.  At first I used the 'Calculate Field' tool for each field. Of course to do this I had to use the tool three times, one for each field.  Next I tried using one update cursor and thus doing all three updates in one loop through the feature class. I found it shaved off 3-4 seconds. 

If you need to go through and calculate multiple fields then you may want to consider using the Update Cursor instead of the 'Calculate Field' tool. It could save you a lot of time.
2 Replies
DavidWasserman
Regular Contributor

I actually logged on to look for someone who did this. Thanks.

David Wasserman, AICP
SepheFox
Frequent Contributor

Thanks for sharing your tip, George!

0 Kudos