feat(postcodes/TZ): 3,684 NAPA Tanzania codes (#1039)#1506
Merged
Conversation
Adds Tanzania's 5-digit National Postal Authority (NAPA) postcodes from the Msuluzya/TanzaniaRegions MIT-licensed mirror. Why --- Closes the TZ gap on issue #1039. The previously-tracked meshackjr/Tanzania-Postal-Codes-SQL covered only Dar es Salaam (1 of 31 regions). Msuluzya covers 24 mainland regions with full ward/locality hierarchy. Coverage -------- - 3,684 codes / 100% state FK - 24 of 31 CSC TZ regions covered Source structure ---------------- 4-level nest: Region -> District -> Ward -> places (5-digit codes). Some wards also have streets/villages arrays for representative locality names. State FK strategy ----------------- Direct region-name match + 10-entry SOURCE_TO_CSC_NAME alias map handling Swahili region labels: Kaskazini Pemba -> Pemba North Kusini Pemba -> Pemba South Kaskazini Unguja -> Zanzibar North Kusini Unguja -> Zanzibar South Mjini Magharibi -> Zanzibar West plus English-variant aliases for 'Zanzibar Central/South' -> 'Zanzibar South' and 'Zanzibar Urban/West' -> 'Zanzibar West'. Coverage gaps ------------- - 7 CSC regions absent (no rows): Dar es Salaam + 5 Zanzibar/Pemba island regions (source ships empty `places` arrays for all of them) + Arusha (source's `places` array there contains village names, not postcodes — 1,432 entries skipped at regex check). - The Arusha source-data shape inconsistency is a known upstream quirk; the strict regex check correctly filters out the malformed data without polluting valid rows. License ------- Msuluzya/TanzaniaRegions: MIT. Upstream: Tanzania National Postal Authority (NAPA). Each row: source: "tanzania-napa-via-msuluzya" Validation ---------- - python3 -m py_compile passes - 100% regex match (^\d{5}$) - 100% state_id valid + state.country_id == 218 + 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>
Contributor
CSC Validation ReportPR Format
Labels applied:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
meshackjr/Tanzania-Postal-Codes-SQL(1/31 regions)Source
Msuluzya/TanzaniaRegions— MIT-licensedjson/tanzania-regions.json(~545 KB)Research-doc correction
The research doc Tier B note for Tanzania read
Only Dar es Salaam (1/31 regions). That was based onmeshackjr/Tanzania-Postal-Codes-SQL. Direct probe of the GitHub ecosystem found Msuluzya's MIT-licensed comprehensive mirror covering 24+ regions.Source structure
4-level nest:
Region → District → Ward → places (5-digit codes). Each ward also carriesstreets/villagesarrays for representative locality names.State FK strategy
Direct region-name match handles 18 of 24 covered regions. 10-entry
SOURCE_TO_CSC_NAMEalias map handles the Swahili island variants:Kaskazini Pemba→Pemba NorthKusini Pemba→Pemba SouthKaskazini Unguja→Zanzibar NorthKusini Unguja→Zanzibar SouthMjini Magharibi→Zanzibar West…plus English-variant aliases for
'Zanzibar Central/South'→'Zanzibar South'and'Zanzibar Urban/West'→'Zanzibar West'.Coverage gaps
placesarrays for all of them).placesarray there contains village names instead of postcodes (1,432 entries). Strict regex check (^\d{5}$) correctly filters them — no malformed data leaks through.Distribution (top 5)
Test plan
python3 -m py_compile bin/scripts/sync/import_tanzania_postcodes.py^\d{5}$id,created_at,updated_at,flag)🤖 Generated with Claude Code