Does anyone have a Python script to populate a field based on the code of another field in the same table?
f(!CODEFIELD!)
def f(code): codelist = ['a','b','c'] valuelist = [10,20,30] value = valuelist[codelist.index(code)] return value
This may be simple but I am only a beginner. Does anyone have a Python script to populate a field based on the code of another field in the same table? Or do have any recommendations where I might find a script?Thank youPam
import arcpy cur = arcpy.UpdateCursor(r"c:\your file") #put in your file path here for row in cur: row.fieldName1 = row.fieldName2 #here I am copying the data from one field to another, just add your own code here. cur.updateRow(row) #transfer the row changes from memory to the table
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.