Hello,
I made this update cursor script to update a three fields based on one field, but it doesn't update any. Ive checked and all field names are currect. Any advice?
Thanks!
updateFields = ["BarrierTyp", "StructureCategory", "StructureClass", "Diversion"]
with arcpy.da.UpdateCursor(schemaone, updateFields) as cursor:
for row in cursor:
if row[0] is None:
continue
if row[0] == "Water Diversion":
row[1] == 3
row[2] == 31
row[3] == 1
elif row[0] == "Manmade Dam":
row[1] == 9
row[2] == 0
row[3] == 0
else:
row[1] == 0
row[2] == 0
row[3] == 0
cursor.updateRow(row)
Change the equality statements (==) to assignment (=) for everything that's not part of an if statement.
updateFields = ["BarrierTyp", "StructureCategory", "StructureClass", "Diversion"]
with arcpy.da.UpdateCursor(schemaone, updateFields) as cursor:
for row in cursor:
if row[0] is None:
continue
if row[0] == "Water Diversion":
row[1] = 3
row[2] = 31
row[3] = 1
elif row[0] == "Manmade Dam":
row[1] = 9
row[2] = 0
row[3] = 0
else:
row[1] = 0
row[2] = 0
row[3] = 0
cursor.updateRow(row)