I have a basic UpdateCursor to update a field value but for some reason the row with "5280" won't update to "1". It only updates the "10560" to "2".
it's probably something i am over looking but not sure what's going on. Any help would be great.
arcpy.Buffer_analysis(SP, outfile, distance, "OUTSIDE_ONLY", "ROUND", "", "BUFF_DIST")
arcpy.Merge_management(["wp2 Mile","wp1 Mile"], "1_2")
with arcpy.da.UpdateCursor("1_2" , "BUFF_DIST") as cursor:
for row in cursor:
if row[0] == 5280:
row[0] = '1'
elif row[0] == 10560:
row[0] = '2'
cursor.updateRow(row)
del row
I have tried else: but i get the same results.
with arcpy.da.UpdateCursor("1_2" , "BUFF_DIST") as cursor:
for row in cursor:
if row[0] == 5280:
row[0] = '1'
else:
row[0] = '2'
cursor.updateRow(row)
del row
Solved! Go to Solution.
Your indenting is wrong. Bump your updateRow back four spaces. Or, just add another cursor.updateRow(row) for the first if.
Your indenting is wrong. Bump your updateRow back four spaces. Or, just add another cursor.updateRow(row) for the first if.
Thanks!