View Source AddressUS.Parser (AddressUS v0.4.2)

Parses US Addresses.

Summary

Functions

Parses a raw address into all of its requisite parts according to USPS suggestions for address parsing.

Parses the raw street portion of an address into its requisite parts according to USPS suggestions for address parsing.

Parses a csv, but instead of parsing at every comma, it only splits at the last one found. This allows it to handle situations where the first value parsed has a comma in it that is not part of what you want to parse.

Functions

Link to this function

parse_address(messy_address)

View Source

Parses a raw address into all of its requisite parts according to USPS suggestions for address parsing.

Known Bugs

1) if street suffix is left off while parsing a full multi-line address,
it will fail unless there is a comma or newline separating the street
name from the city.

Examples

iex> AddressUS.Parser.parse_address("2345 S B Street, Denver, CO 80219")
%AddressUS.Address{city: "Denver", plus_4: nil, postal: "80219",
state: "CO", street: %AddressUS.Street{name: "B", pmb: nil,
post_direction: nil, pre_direction: "S", primary_number: "2345",
secondary_designator: nil, secondary_value: nil, suffix: "St"}}
Link to this function

parse_address_line(invalid)

View Source

Parses the raw street portion of an address into its requisite parts according to USPS suggestions for address parsing.

Examples

iex> AddressUS.Parser.parse_address_line("2345 S. Beade St")
%AddressUS.Street{name: "Beade", pmb: nil, post_direction: nil, pre_direction: "S",
primary_number: "2345", secondary_designator: nil, secondary_value: nil,
suffix: "St"}

Parses a csv, but instead of parsing at every comma, it only splits at the last one found. This allows it to handle situations where the first value parsed has a comma in it that is not part of what you want to parse.

Example

iex> AddressUS.Parser.parse_csv("test/test.csv")
%{"Something Horrible, (The worst place other than Wyoming)" => "SH",
"Wyoming" => "WY"}