# How to Parse Unique Address Data

I'm trying to parse some funky address data into separate fields either using ArcMap's Field Calculator or a Python Script. Currently, my address data including street number, street name, and unit/apt/suite number are all in one field. Some examples of the diversity in my data include:

1111 2ND ST
1753 21ST ST 2ND FLOOR
2125 ARIZONA AVE #303
2424 12TH ST SUITE 100

Thankfully, there are only a handful of suffixes which include:

AV | AVE | BL | CT | DR | LANE | PKWY | PL | RD | ST | TER | WAY

What python methods could I employ to search for these unique identifiers and then split whatever follows them (e.g., "2ND FLOOR", "#303", "SUITE 100")?

You would use .split method for this.

``````inStr = "1753 21ST ST 2ND FLOOR"
result = inStr.split(' ST ')
print result

>>>['1753 21ST', '2ND FLOOR']
``````

Keep in mind that result is the list which you would need to iterate if you want to get hands at individual element of the address. If you will need to work with the address items in a more advanced way, you will inevitably come to using regular expressions with ArcGIS or Python.

To take care of all possible cases, I've provided a list of separators. The assumption is that the separators are always embraced by whitespaces on both sides - ' ST ' and ' AVE ' and so forth:

``````inStrings = ["1753 21ST ST 2ND FLOOR","2125 ARIZONA AVE #303","2424 12TH TER SUITE 100"]

separators = ["AV","AVE","BL","CT","DR","LANE","PKWY","PL","RD","ST","TER","WAY"]

for separator in separators:
if len(address.split(' {0} '.format(separator))) > 1:

>>>[['1753 21ST', '2ND FLOOR'], ['2125 ARIZONA', '#303'], ['2424 12TH', 'SUITE 100']]
``````

Output can be also be written with list comprehensions (harder to read yet more compact and sometimes faster):

``````outAddresses = [address.split(' {0} '.format(separator)) for separator in separators for address in inStrings
if len(address.split(' {0} '.format(separator))) > 1]
``````
• Glad it's helpful. Regular expressions are scary, but you can do the magic when you master them :) (I have used them just a couple of times for some simple things). If it is for a quick fix with addresses, then don't mess with regexs and just do some splitting with the separators as I explained. – Alex Tereshenkov May 7 '15 at 18:00

USPS recognizes not 12 but close to 200 possible street suffixes, plus there are countless possible misspellings of them.

With real life data that is not 100% clean and standardized, you will have a better luck with an address validation API, such as YAddress (made by the company I work for). After correcting and standardizing the address, YAddress breaks down the street part into 7 different components -- pre-direction, post-direction, suffix, etc.