Skip to main content

Simple script that permits to parse addresses in France format.

Project description

FRAPARS (France-parse-addresses)

Simple script that permits to parse addresses in France format.

Install

To install the package from pypl use the command

pip install frapars

or with Poetry: poetry add frapars

Example of usage

The package can be used to process multiple or single addresses. Here few example.

Use this to import the library:

from frapars.functions.addresses import parse_from_address, parse_all_parallel

Then, for single usage:

address = "3 Rue Industrie (De l')"
result = parse_from_address(address)
print(result)

Obtaining

[{'raw': 'Jaures (128, Avenue Jean)', 'urba_names': ['avenue'], 'city': [], 'address_num': ['128'], 'department': [], 'street_name': ['jaures', 'jean'], 'formatted': '128 Avenue Jaures Jean'}, {'raw': 'Ferdinand Buisson (42, Rue)', 'urba_names': ['rue'], 'city': ['buisson'], 'address_num': ['42'], 'department': [], 'street_name': ['ferdinand'], 'formatted': '42 Rue Ferdinand Buisson'}]

Use the fields .raw and .formatted and .details to retrieve the specifica value that you need.

For List of addresses:

adresses_list = ["Hommelet (31, rue de l'), 59512, ROUBAIX", ' Allée Combes (Des)', " 3 Rue Industrie (De l')", ' Route Départementale 49', ' 02210 Rozet Saint Albin', ' Pont Romain, 12, Rue Du', ' Chaussée (11, Rue de la )', ' Jaures (128, Avenue Jean) et Ferdinand Buisson (42, Rue)', ' Jacquart (50, 52 Rue) ', ' Lecat (50, Rue)', ' Deguise Olivier (3, Rue)   Rd360', " Lieu Dit 'L'Italie"]

parsed_addresses = parse_all_parallel(adresses_list)
for entry in result:
    print(f"Raw: {entry.raw} --> Formatted: {entry.formatted}")

This will print something like:

Raw: Hommelet (31, rue de l'), 59512, ROUBAIX --> Formatted: 31 Rue De L Hommelet Roubaix 59512
Raw:  Allée Combes (Des) --> Formatted: Allée Des Combes
Raw:  3 Rue Industrie (De l') --> Formatted: 3 Rue De L Industrie
Raw:  Route Départementale 49 --> Formatted: 49 Route Départementale
Raw:  02210 Rozet Saint Albin --> Formatted: Rozet Saint Albin 02210
Raw:  Pont Romain, 12, Rue Du --> Formatted: 12 Rue Du Pont Romain
Raw:  Chaussée (11, Rue de la ) --> Formatted: 11 Rue De La Chaussée
Raw:  Jaures (128, Avenue Jean) et Ferdinand Buisson (42, Rue) --> Formatted: 128 Avenue Jaures Jean et 42 Rue Ferdinand Buisson
Raw:  Jacquart (50, 52 Rue)  --> Formatted: 50-52 Rue Jacquart
Raw:  Lecat (50, Rue) --> Formatted: 50 Rue Lecat
Raw:  Deguise Olivier (3, Rue)   Rd360 --> Formatted: 3 Rue Deguise Olivier
Raw:  Lieu Dit 'L'Italie --> Formatted: Lieu Dit L Italie

In case you want a specific format template there is a Format() object to do so.

from frapars.helper.formatter import Formatter, AddressFields

address = "Jaures (128, Avenue Jean) 10141, France, FR"
result = parse_from_address(address, Formatter(
    template=f"{AddressFields.ADDRESS_NUM.value} - {AddressFields.CITY.value} - {AddressFields.POSTCODE.value}"
))
print(result.formatted)
print('/n')
print(result)

Returning:

42 - Ferdinand - Buisson

[{'raw': 'Jaures (128, Avenue Jean)', 'urba_names': ['avenue'], 'city': [], 'address_num': ['128'], 'department': [], 'street_name': ['jaures', 'jean'], 'formatted': '128 - Jaures Jean -'}, {'raw': 'Ferdinand Buisson (42, Rue)', 'urba_names': ['rue'], 'city': ['buisson'], 'address_num': ['42'], 'department': [], 'street_name': ['ferdinand'], 'formatted': '42 - Ferdinand - Buisson'}]

To-Do List

  • Write junit tests
  • More example
  • Update insee file - create a task that do it

Enjoy and Rate!!

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

frapars-0.2.6.tar.gz (778.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

frapars-0.2.6-py3-none-any.whl (785.6 kB view details)

Uploaded Python 3

File details

Details for the file frapars-0.2.6.tar.gz.

File metadata

  • Download URL: frapars-0.2.6.tar.gz
  • Upload date:
  • Size: 778.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/23.5.0

File hashes

Hashes for frapars-0.2.6.tar.gz
Algorithm Hash digest
SHA256 62550b5464447d9cf2bc8368cf3fb6a065f7e5c8e7f8abf4a2d1823878b25dac
MD5 89820dc76d423ab379ce2ac43f005ab8
BLAKE2b-256 9b5fc4b9760ae6b9c8e796b71b3c2caa68934c0c10e34a1805a663b918dee8c7

See more details on using hashes here.

File details

Details for the file frapars-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: frapars-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 785.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/23.5.0

File hashes

Hashes for frapars-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 824f5a0da91d2d3632487f23862ecd912c6313eb2ebc43c112a188da202eed96
MD5 c7e67c56a58c17d5c8bdd872e361d528
BLAKE2b-256 f2be5b7967273701d357487b9e1c4901b0d717631a980c119a269d8da11662f1

See more details on using hashes here.

Supported by

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