Normalize Beninese phone numbers (2024 ten-digit plan, E.164) and emails, with explicit statuses for every real-world anomaly
Project description
benin-contacts
Normalize Beninese phone numbers and emails, with an explicit status for every real-world anomaly. Battle-tested on 496,729 rows of Benin's national business directory in the annuaire-benin pipeline.
On 30 November 2024, Benin migrated from an 8-digit to a 10-digit numbering
plan (every number gained the "01" prefix). Real datasets mix both eras, plus
lost leading zeros from numeric spreadsheet cells, country-code prefixes, and
numbers truncated by exports. This library converts everything convertible to
canonical E.164 (+22901XXXXXXXX) and names what it cannot convert instead
of guessing digits.
from benin_contacts import normalize, extract_all, PhoneStatus
normalize("97 00 00 01")
# PhoneResult(raw='97 00 00 01', e164='+2290197000001', status=PhoneStatus.MIGRATED)
normalize(197000001) # leading zero lost by a numeric cell
# PhoneResult(..., e164='+2290197000001', status=PhoneStatus.LEADING_ZERO_RESTORED)
normalize("01970001") # 8 chars starting with 01: truncated by the export
# PhoneResult(..., e164=None, status=PhoneStatus.SUSPICIOUS_SHORT_01)
extract_all("97 00 00 01 / 96 00 00 02") # multi-number cells
# [PhoneResult(...MIGRATED), PhoneResult(...MIGRATED)]
Statuses: ALREADY_MIGRATED, MIGRATED, LEADING_ZERO_RESTORED,
SUSPICIOUS_SHORT_01, INVALID, EMPTY. Each carries status.is_valid.
Email side: benin_contacts.emails.normalize (lowercasing, whitespace,
pragmatic syntax check).
pip install benin-contacts
En français
Normalisation des numéros béninois vers le plan à 10 chiffres de novembre 2024 (format E.164), avec un statut explicite pour chaque anomalie : zéros de tête perdus, indicatifs pays, cellules multi-numéros, et surtout les numéros tronqués par un export (8 chiffres commençant par « 01 »), marqués plutôt que « réparés » en inventant des chiffres. Validation syntaxique des emails. Éprouvé sur les 496 729 lignes de l'annuaire national des entreprises du Bénin.
License
MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file benin_contacts-0.1.0.tar.gz.
File metadata
- Download URL: benin_contacts-0.1.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bd8d1c436d05800d583e4bf808f0271b495b6f61083706c69fb39757248f54a
|
|
| MD5 |
91cf057dcd69cf7216adbdf80532fdc9
|
|
| BLAKE2b-256 |
c3d956433dc241fa9e9d777e7b4ad1f5345b78b2999a42f3011bcee2db75edd1
|
File details
Details for the file benin_contacts-0.1.0-py3-none-any.whl.
File metadata
- Download URL: benin_contacts-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b780980449cbe94afe7b02f9e966c290bb26f5194d6033cc7da3288fb955e0e7
|
|
| MD5 |
afc12bcca73061703653515367e1ec02
|
|
| BLAKE2b-256 |
339c40db74bb80554a31fe7572e45c1eebff79abe07d07d148934bef69512859
|