Is there a library for parsing US addresses?

WeaselFox picture WeaselFox · Feb 27, 2012 · Viewed 21.9k times · Source

I have a list of US addresses I need to break into city,state, zip code,state etc.

example address : "16100 Sand Canyon Avenue, Suite 380 Irvine, CA 92618"

Does anyone know of a library or a free API to do this? Google/Yahoo geocoder is forbidden to use by the TOS for commercial projects..

It would be awesome to find a python library that preforms this.

Answer

Tyler Hayes picture Tyler Hayes · Mar 7, 2015

Quite a few of these answers are a few years old now.

The most bulletproof library I've seen recently is usaddress: https://github.com/datamade/usaddress:

Pro tip: when testing addresses in all these libraries, use 1) no commas in your address, 2) multi-word city names preferably with "St." in the name to see if the library can differentiate between "street" and "Saint" (e.g., St. Louis), and 3) improper casing. This combo will typically make even the better parsers fall down.