Skip to main content

No project description provided

Project description

br-address-parser

This module is a simple parser for Brazilian addresses. This receives a complete address string and split it in 'street', 'number', 'complement', 'neighborhood', 'city' and 'state'.

This code is a br-address-parser port for Python. Credits should go to the original implementation contributors.

How to install

pip install br_address_parser

How to use

from br_address_parser import parse

complete_address = "Av. Brasil, 1245 - Bloco 2 Ap 203 - Centro - Belo Horizonte - MG"
parsed_address = parse(complete_address)

The above example transforms the string "Av. Brasil, 1245 - Bloco 2 Ap 203 - Centro - Belo Horizonte - MG" into the following object:

{
    "street": "Av. Brasil",
    "number": "1245",
    "complement": "Bloco 2 Ap 203",
    "neighborhood": "Centro",
    "city": "Belo Horizonte",
    "state": "MG"
}

If you want to fill some fields with default values when they are empty, then you can use defaultFields parameter:

complete_address = "AV ANAVILLE 1-QD 3 LT 4 - RESIDENCIAL ANAVILLE - ANAPOLIS - GO"
parsed_address = parse(complete_address, {"number": "S/N"})

The above example transforms will put S/N in the number field, because parsed address returns empty number:

{
   "street": "AV ANAVILLE 1",
   "number": "S/N",
   "complement": "QD 3 LT 4",
   "neighborhood": "RESIDENCIAL ANAVILLE",
   "city": "ANAPOLIS",
   "state": "GO"
}

When the address cannot be parsed, the parse function returns None.

How to test

make test

License

This project is licensed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

br_address_parser-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file br_address_parser-0.1.0.tar.gz.

File metadata

  • Download URL: br_address_parser-0.1.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.3

File hashes

Hashes for br_address_parser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4c092ccd87d49c72e457f27d9e531c0d6e07625cca110fab0a72403f4e081468
MD5 f518491d8c3a150c52364b4711ef2ed2
BLAKE2b-256 4a8cb0212ac1d4d272cade9a132efc6899e3bf8bd9c5e7e6fd607a7022989662

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page