Skip to content

feat(postcodes/TN): 4,868 La Poste Tunisienne codes (#1039)#1505

Merged
dr5hn merged 1 commit into
masterfrom
feat/postcodes-tunisia
May 5, 2026
Merged

feat(postcodes/TN): 4,868 La Poste Tunisienne codes (#1039)#1505
dr5hn merged 1 commit into
masterfrom
feat/postcodes-tunisia

Conversation

@dr5hn
Copy link
Copy Markdown
Owner

@dr5hn dr5hn commented May 2, 2026

Summary

  • Imports Tunisia's full 4-digit La Poste Tunisienne postcode dataset (4,868 codes) for Can we add a postcode for this? #1039
  • 100% state FK resolution across all 24 governorates
  • Supersedes the earlier-considered hajer77/postCodeTunisia-api stub (~9 records / 8 govs)

Source

Research-doc correction

Per the research doc Tier B note, Tunisia was previously categorised as Stub only (8/24 governorates, 9 records). That was based on hajer77/postCodeTunisia-api. Direct probe shows two community mirrors with full 24-governorate coverage:

  • hbj/tnpostcodes — 4,859 records (uppercase)
  • JenhaniChedli/TunisiaGeodataAPI — 4,868 records (Title Case)

Both scrape La Poste Tunisienne's public lookup. JenhaniChedli has slightly more records and standard JSON.

State FK

ASCII-fold + name match handles 23 of 24 governorates. One alias:

  • 'Mannouba' (source spells with double n) → CSC 'Manouba'

'Beja' / 'Gabes' (no diacritics in source) match CSC 'Béja' / 'Gabès' via NFKD fold.

Distribution (top 5)

iso2 governorate rows
21 Nabeul 373
13 Ben Arous 317
61 Sfax 332
31 Béja 310
43 Sidi Bouzid 266

All 24 govs covered.

Test plan

  • python3 -m py_compile bin/scripts/sync/import_tunisia_postcodes.py
  • All 4,868 codes match ^\d{4}$
  • 100% state_id valid; state.country_id == 224; state_code == state.iso2
  • No auto-managed fields (id, created_at, updated_at, flag)
  • Idempotent merge (re-run produces no diff)

🤖 Generated with Claude Code

Adds the full Tunisian 4-digit postal code dataset from the
JenhaniChedli/TunisiaGeodataAPI mirror.

Why
---
Closes the TN gap on issue #1039. The previously-tracked
hajer77/postCodeTunisia-api source was a stub (~9 records, 8/24
governorates). JenhaniChedli's mirror covers all 24 governorates
with the full Gouvernorat / Délégation / Cité hierarchy.

Coverage
--------
- 4,868 codes / 100% state FK
- All 24 CSC TN governorates covered

State FK strategy
-----------------
ASCII-fold + name match against states.json + 1 alias for
'Mannouba' -> CSC 'Manouba' (single-letter spelling drift).
'Beja'/'Gabes' (no diacritics in source) match CSC 'Béja'/'Gabès'
via ASCII fold.

License
-------
Source: JenhaniChedli/TunisiaGeodataAPI (no formal LICENSE file).
Upstream: La Poste Tunisienne publicly published codes.
Tier 5 per #1039 license-tier policy.
Each row: source: "la-poste-tunisienne-via-jenhani-chedli"

Validation
----------
- python3 -m py_compile passes
- 100% regex match (^\d{4}$)
- 100% state_id valid + state.country_id == 224 + state_code agrees
- No auto-managed fields (id, created_at, updated_at, flag)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. enhancement New feature or request labels May 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

CSC Validation Report

PR Format

  • ✅ Description provided
  • ✅ Data source linked
  • ✅ Issue linked (recommended for data changes)
  • ✅ Justification / context provided

Labels applied: data:postcodes, large-contribution

⚠️ Large Contribution

This PR contains 4868 records. Large contributions require manual review.

Schema Validation (4868 records)

✅ All records passed validation

Cross-Reference Validation

✅ 9736 reference(s) verified

Source URL Verification

✅ 2 source URL(s) accessible


All checks passed | Status: Ready for review

@dr5hn dr5hn merged commit 97ab1cb into master May 5, 2026
1 check passed
@dr5hn dr5hn deleted the feat/postcodes-tunisia branch May 5, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data:postcodes enhancement New feature or request large-contribution ready-for-review size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant