AddressUS.Parser (AddressUS v0.4.1) View Source
Parses US Addresses.
Link to this section Summary
Functions
Abbreviates the state provided.
Removes non-numeric characters from the phone number and then returns the integer.
Removes country code and associated punctuation from the phone number.
Converts the country to the 2 digit ISO country code. "US" is default.
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.
Link to this section Functions
Abbreviates the state provided.
Example
iex> AddressUS.Parser.abbreviate_state("Wyoming")
"WY"
iex> AddressUS.Parser.abbreviate_state("wyoming")
"WY"
iex> AddressUS.Parser.abbreviate_state("Wyomin")
"Wyomin"
iex> AddressUS.Parser.abbreviate_state(nil)
nil Removes non-numeric characters from the phone number and then returns the integer.
Examples
iex> AddressUS.Parser.clean_phone_number("(303) 310-7802")
3033107802 Removes country code and associated punctuation from the phone number.
Examples
iex> AddressUS.Parser.filter_country_code("+1 303-310-7802")
"303-310-7802"
iex> AddressUS.Parser.filter_country_code("+1 (303) 310-7802")
"(303) 310-7802"
iex> AddressUS.Parser.filter_country_code("+1-303-310-7802")
"303-310-7802"
iex> AddressUS.Parser.filter_country_code("1-303-310-7802")
"303-310-7802" Converts the country to the 2 digit ISO country code. "US" is default.
Example
iex> AddressUS.Parser.get_country_code(nil)
"US"
iex> AddressUS.Parser.get_country_code("Afghanistan")
"AF"
iex> AddressUS.Parser.get_country_code("AF")
"AF" 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")
%Address{city: "Denver", plus_4: nil, postal: "80219",
state: "CO", street: %Street{name: "B", pmb: nil,
post_direction: nil, pre_direction: "S", primary_number: "2345",
secondary_designator: nil, secondary_value: nil, suffix: "St"}} 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")
%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"}