As the title says, I am using arcpy.da.UpdateCursor() and I can't get it to update the rows. My code is below. (Yes, I know I am still working with a nested cursor... I haven't decided if a dictionary is the right way to go for my purposes yet. That's for another topic.)
fields = ["SOIL", "MAX_SLOPE", "MIN_CDA", "MAX_CDA", "WT_SEP", "WT_RELAX",
"COAST_SEP", "MIN_DEPTH", "DEPTH_RELA", "COAST_MIN_", "BMP", "MOD"]
for row in arcpy.da.SearchCursor(combo_table, ["DARAS", "HSG", "MEDSLOPE", "MEDWT"]):
print("Saving constraint table for DA " + str(row[0]) + " and HSG " + str(row[1]) + "...")
arcpy.Copy_management(compare, BMPFold + "\\" + "DA" + str(row[0]) + "HSG" + str(row[1]))
arcpy.AddField_management(BMPFold + "\\" + "DA" + str(row[0]) + "HSG" + str(row[1]), "MOD", "TEXT", "", "", 25)
with arcpy.da.UpdateCursor(BMPFold + "\\" + "DA" + str(row[0]) + "HSG" + str(row[1]), fields) as cursor:
for r in cursor:
# Compare water table depths
if r[4] + r[7] > row[3]:
if r[5] == 1:
coast_WT = r[6]
else:
coast_WT = r[4]
if r[8] == 1:
coast_depth = r[9]
else:
coast_depth = r[7]
if coast_WT + coast_depth < row[3]:
if r[5] == 1 and r[8] == 1:
r[11] = "Separation and Depth"
print("Modifying " + str(r[11]) + "allows for " + str(r[10]) + "...")
elif r[5] == 1:
r[11] = "WT Separation"
print("Modifying " + str(r[11]) + "allows for " + str(r[10]) + "...")
elif r[8] == 1:
r[11] = "Practice Depth"
print("Modifying " + str(r[11]) + "allows for " + str(r[10]) + "...")
cursor.updateRow(r)
if coast_WT + coast_depth > row[3]:
print("Removing " + str(r[10]) + " from DA " + str(row[0]) +
" HSG " + str(row[1]) +" based on water table proximity...")
cursor.deleteRow()
As the title states, I am not getting any errors when I run this code. When I open my file, the "MOD" field is blank for all rows still. My print statements are not printing before or after the r[11] = "TEXT" line even when they are modified to exclude calling r[11]. They worked at one point while I was getting errors with cursor.updateRow() but now there's nothing. My last print statement works, "Removing ..." though.