I created a model that runs, but want it as a script. I exported it and made some small changes, but now I'm getting an error in the Field Calculation. Excerpt from the code: I created a field:
arcpy.AddField_management(Final, "mobCode", "TEXT", "", "", "12", "", "NULLABLE", "NON_REQUIRED", "")
Then, I calculate the field "mobCode":
arcpy.CalculateField_management(final_shp, "mobCode", "mob(!gridcode!, !soil_code!, !mobCode!)", "PYTHON_9.3", "def mob(fld1, fld2, mobCode):
if fld1 >0 and fld1 <=15 and fld2 == \"Good\":
return \"Go\"
elif fld1 >15 and fld1 <45 and fld2 == \"Good\":
return \"Slow Go\"
elif fld1 >0 and fld1 <=15 and fld2 == \"Fair\":
return \"Slow Go\"
elif fld1 >15 and fld1 <45 and fld2 == \"Fair\":
return \"No Go\"
elif fld1 >45:
return \"No Go\"
else:
return \"No Cal\"")
I get an EOL string literal error at the arcpy.CalculateField_management line behind the colon.
I've referenced this page, but...not quite getting it: Error calculating field with script exported from ModelBuilder
I also read that it's better to develop the codeblock as its own variable (maybe codeblock)?