Solved! Go to Solution.
import arcpy from arcpy import env env.workspace = r"C:\temp\python\test.gdb" fc = "featureClass" with arcpy.da.UpdateCursor(fc, ["field1", "field2"]) as cursor: for row in cursor: if row[0] == 1: row[1] = 'Woodland' if row[0] == 2: row[1] = 'Arable' ...... ..... cursor.updateRow(row) del cursor, row
import arcpy from arcpy import env env.workspace = r"C:\temp\python\test.gdb" fc = "featureClass" with arcpy.da.UpdateCursor(fc, ["field1", "field2"]) as cursor: for row in cursor: if row[0] == 1: row[1] = 'Woodland' if row[0] == 2: row[1] = 'Arable' ...... ..... cursor.updateRow(row) del cursor, row
Hi Mark,
Here is an example on how to do this using the arcpy.da.UpdateCursor (10.1 or beyond is required):import arcpy from arcpy import env env.workspace = r"C:\temp\python\test.gdb" fc = "featureClass" with arcpy.da.UpdateCursor(fc, ["field1", "field2"]) as cursor: for row in cursor: if row[0] == 1: row[1] = 'Woodland' if row[0] == 2: row[1] = 'Arable' ...... ..... cursor.updateRow(row) del cursor, row