import arcpy arcpy.env.workspace = r"K:\Data\PythonTest.gdb" fc = "FeatureClass" #Create list of fields that begin with "WR_" .. I want to multiply all of these together and write values to a new field "Product" FieldList = arcpy.ListFields(fc, "WR_*", "All") rows = arcpy.UpdateCursor(fc) for field in FieldList: fName = field.name print fName #Everything up to here works-- I get a list of the fields I want #Open an update cursor for row in rows: for field in FieldList: CurrVal = row.getValue(field) # this doesn't work & I'm not sure how to proceed from here
Solved! Go to Solution.
rows = arcpy.UpdateCursor(fc) for row in rows: Val = 1 for field in fieldList: CurrVal = row.getValue(field.name) Val = Val * CurrVal # Or whatever you want to do to the values row.NewField = Val rows.updateRow(row)
rows = arcpy.UpdateCursor(fc) for row in rows: Val = 1 for field in fieldList: CurrVal = row.getValue(field.name) Val = Val * CurrVal # Or whatever you want to do to the values row.NewField = Val rows.updateRow(row)