feat(postcodes/IT): bulk-import 4,678 CAP codes via Istat (#1039)#1436
Merged
Conversation
Adds the importer + first run for Italy. Uses the matteocontrini/comuni-json mirror of Istat's official Italian commune list with postcodes (CAP). 1. bin/scripts/sync/import_italy_postcodes.py — pipeline reading the community-maintained UTF-8 JSON. Each commune has a cap[] array (large cities like Rome have 80+ CAPs); pipeline expands one row per (cap, commune) and picks first commune alphabetically as canonical per code. State resolution is direct sigla -> state.iso2 match (RM=Rome, MI=Milan, etc.) with one alias bridge: Aosta uses sigla 'AO' but states.json has it as the 'Aosta Valley' autonomous region with iso2 '23'. 2. contributions/postcodes/IT.json — 4,678 unique CAPs covering all 7,904 comuni with 100% state_id resolution. Multi-CAP cities - Rome: 82 CAPs - Venice: 56 - Messina: 48 - Genoa: 47 - Milan: 42 - Each CAP gets one record pointing to the canonical commune name; this matches the Tier-4 "one row per code" contract from #1398. Validation (zero errors across 4,678 records) - All codes match countries.postal_code_regex (^(\\d{5})\$) - All FKs resolve, all state_codes agree with state.iso2 - No auto-managed fields present License & attribution - Upstream: Istat (CC-BY 3.0) - Mirror: github.com/matteocontrini/comuni-json - Each row: source: "istat" Refs: #1039 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
Adds Italian postcodes via the matteocontrini/comuni-json mirror of Istat's official commune list with CAP.
bin/scripts/sync/import_italy_postcodes.py— pipeline expanding each commune'scap[]array to one record per (cap, commune), picking first-alphabetical commune per unique CAP. State resolution by sigla → state.iso2 with one alias bridge (AostaAO→23).contributions/postcodes/IT.json— 4,678 unique CAPs across all 7,904 comuni, 100% state_id resolution.Multi-CAP cities
Each CAP gets one record pointing to the canonical commune (matches the Tier-4 "one row per code" contract from #1398).
Validation (zero errors across 4,678 records)
state_idresolved^(\d{5})$state_code↔state.iso2agreementLicense
github.com/matteocontrini/comuni-jsonsource: "istat"Cumulative postcode coverage after this lands
~223,000 postcode rows across 23 countries.
Refs: #1039