My requirement is to update the codes in CODE field as per the name (Example list is given right side) for 50000 features, like if name is AAA, then code will be 419, if name is ABC, then code is 420.
I have 850 different codes and I want to update all 850 at once in shapefile. I can update two or three values by using below code but I don't know how to update 850 codes.
import arcpy from arcpy import env env.workspace = r"C:\\data\test.shp" env.workspace = fc fclist = arcpy.ListFeatureClasses() for fc in fclist : fields = ["name", "code"] with arcpy.da.UpdateCursor(fc, fields) as cursor: for row in cursor: if row == "AAA" row = 419 elif: if .row == "BBB" row = 420 cursor.updateRow(row) print "codes updated"
If I want to update all 850 codes, need to write if...else statement 850 times to update all codes. I have saved all names and codes in Excel. So instead of writing many if else statements, please help how to update all codes based on name by using Excel or CSV file.