How to edit Vector attribute tables using Python/ArcPy?

Method 1: arcpy.UpdateCursor

From:https://gis.stackexchange.com/questions/60458/how-to-edit-attribute-tables-using-python-arcpy

This should do it and is a little simpler than the examples in the online help for UpdateCursorwhich is nevertheless worth a read.

I’ve assumed your shapefile is in a folder called C:\temp and that structuretype is an integer field. If it is a text field just use “3” and “4” instead of 3 and 4.

import arcpy

features = arcpy.UpdateCursor(r"C:\temp\Structures.shp")
for feature in features:
    if feature.structuretype == 3:
        feature.structuretype = 4
        features.updateRow(feature)
del feature,features

Warning: The way I am referencing field values here only works for old style cursors and not for the superior and faster cursors in the Data Access (arcpy.da) module, which was introduced with ArcGIS 10.1.

Method 2: arcpy.da.UpdateCursor

From: http://pro.arcgis.com/zh-cn/pro-app/arcpy/functions/updatecursor.htm

转载自:https://blog.csdn.net/dou3516/article/details/83063830

You may also like...