I have a table with about 6k road names. only the FULLSTNAME field is populated. I need to populate the PERDIR (pre directional) STNAME (Street name only), STTYPE (Street type) and POSTDIR (post directional) from the field FULLSTNAME.
To start off i started with field calculator but only a handful of fields get populated.
splitString = inString.split(' ') ###splits the address into a list
a = splitString ### list item 0 is the first part of name
b = splitString ### list item 1 is the prefix
c = ' '.join(splitString[2:-1]) ### this rerurns the street name
d = splitString[-1] ### this returns the suf dir or street type
return a ### depending on what you want to return,
#return b ### un-comment and re-comment out the
#return c ### appropriate value(s)
Even looking at just populating "PREDIR" field with the above filed calculator i would run into problems, for example the road name "New Castle Dr" it would put "New" in the PREDIR field which correct because it is not a Pre- directional. Some roads have two words for names like "New Castle Dr" has "New Castle". if used return c it would only populate the STNAME field with just "New".
I tried looking at using arpy with the following but get an invalid syntax line 15
from arcpy import env
inputTable = "Road_Names_1"
arcpy.AddMessage ("input " + inputTable)
#split field loop
rows = arcpy.UpdateCursor (inputTable) #gets all vlaues for table
for row in rows: #loops through vlaues and updates new field
row.Type = row.FULLSTNAME.split(" ")[-1] if ',' in !FULLSTNAME! then !STNAME!=!FULLSTNAME!.split(',',1)[-1] else ""
I also tried to look at at a post by Ted Kowal of his Address Parase but i am not sure how to use it.
If anyone already has a python script that works and would be willing to share i would really appreciate it.