I am trying to replace the values in my predirection field in ArcMap using the field calculator. Here is my sample code.
def predir(field):
if "S" in fields:
return field.replace("S","South")
elif "E" in fields:
return field.replace("E","EAST")
elif "W" in fields:
return field.replace("W", "WEST")
elif "N" in fields:
return field.replace("N", "NORTH")
elif "NE" in fields:
return field.replace("NE", "NORTHEAST")
elif "NW" in fields:
return field.replace("NW", "NORTHWEST")
elif "SE" in fields:
return field.replace("SE", "SOUTHEAST")
elif "SW" in fields:
return field.replace("SW", "SOUTHWEST")
else:
return field
I am getting the following error:
Failed to execute. Parameters are not valid
Error 000989: Python syntax error: Parsing error SyntaxError:Invalid syntax(line18)
Failed to execute (Calculate Field).
There are Null values in the field, but they need to be there for NextGen 911 purposes. Any suggestions? I was thinking of using a similar syntax for replacing my post direction and street type values as well. Eventually I will need to put a script together that does all this for my street center lines and structures.