I hope somebody can help with this!
Basically, I have a table with a situs address field and I want to use this field to calculate new fields I have created which are named respectively "HouseNumber", "FullStreetName", "PrefixDirection", "StreetName", and "SuffixType". I am thinking this is a parse function of some sort?
See attached pics of the table I want to populate vs. the table that is already populated. I would do this manually, but I have 96K records to edit.
Solved! Go to Solution.
Oops, missed a dot in my answer, I edited it.
!SITUS_1!.split(" ")[0]
If the format is the same for each address, it's really easy.
You can do it with the field calculator:
# field calculation for HouseNumber
# Python
!FullStreetName!.split(" ")[0]
# other fields are analogous, just use different indexes
Or you can do it all at once with an UpdateCursor:
with arcpy.da.UpdateCursor("AdressLayer", ["SITUS_1", "HouseNumber", "FullStreetName", "PrefixDirection", "StreetName", "SuffixType"]) as cursor:
for row in cursor:
situs = row[0]
number, dir, name, type = situs.split(" ")
full_name = " ".join([dir, name, type])
new_row = [situs, number, full_name, dir, name, type]
cursor.updateRow(new_row)
Hello Johannes,
I would like to use the field calculator. I tried this calc in the "HouseNumber" field:
!SITUS_1!split(" ")[0]
It didn't work. any ideas?
Oops, missed a dot in my answer, I edited it.
!SITUS_1!.split(" ")[0]
Thank you!
Only... how do I get the next set of text? For instance for "FullStreetName" I need the text "SW 125TH TER" from the string "9995 SW 125TH TER".
# HouseNumber
!SITUS_1!.split(" ")[0]
# PrefixDirection
!SITUS_1!.split(" ")[1]
# StreetName
!SITUS_1!.split(" ")[2]
# Street Type
!SITUS_1!.split(" ")[3]
# FullStreetName is a little different: split by space, take everything except the first element (the house number) and join by space
" ".join(!SITUS_1!.split(" ")[1:])
it worked! Thanks!