feat(postcodes/DACH): bulk-import 35,596 codes via OpenPLZ (#1039)#1431
Merged
Conversation
Adds two things in one PR (the script + its first run):
1. bin/scripts/sync/import_openplz_postcodes.py — pipeline that walks
the OpenPLZ REST API hierarchy for Germany, Austria, and
Switzerland, paginating Localities under each region. ODbL-1.0
licensed source matches this repo's licence exactly.
2. Three new contribution files:
contributions/postcodes/DE.json (12,815 records, 2.5 MB)
contributions/postcodes/AT.json (18,722 records, 4.0 MB)
contributions/postcodes/CH.json ( 4,059 records, 840 KB)
Total: 35,596 postcodes across DACH with 100% state_id resolution.
How state resolution works
- DE/CH: exact case-insensitive name match against states.json (with
light umlaut normalisation and a few translation aliases:
Luzern->Lucerne, Genève->Geneva, Basel-Landschaft->Basel-Land,
Fribourg/Freiburg->Fribourg, etc.)
- AT: name match catches the directly-spelt provinces (Salzburg,
Vorarlberg, Burgenland) and aliases handle translations
(Wien->Vienna, Tirol->Tyrol, Steiermark->Styria, Kärnten->Carinthia,
Niederösterreich->Lower Austria, Oberösterreich->Upper Austria).
A postcode-prefix fallback covers the rest (1xxx=Wien, 8xxx=Steiermark,
9xxx=Kärnten, etc.) — Austrian Post's well-documented prefix scheme
is more reliable than fuzzy multilingual name matching.
LI deliberately omitted
- contributions/postcodes/LI.json is already curated (#1401) with 13
high-quality 1:1 commune-to-code rows. OpenPLZ's per-code endpoint
returns multiple sub-localities per code (e.g. Vaduz-Triesen,
Vaduz-Schaan) that would muddy the existing clean mapping.
Validation (zero errors across 35,596 records)
- All codes match countries.postal_code_regex for their ISO2
- All country_id/state_id foreign keys resolve
- All state_code values agree with state.iso2
- No auto-managed fields present (id, created_at, updated_at, flag)
- Idempotent re-runs preserve any future curated rows by (code, locality_name)
License & attribution
- Source: OpenPLZ (https://openplzapi.org), ODbL-1.0
- Each row: source: "openplz" for programmatic attribution
Refs: #1039
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
CSC Validation ReportPR Format
Labels applied:
|
This was referenced Apr 27, 2026
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
Second bulk postcode PR after India (#1430). Adds:
bin/scripts/sync/import_openplz_postcodes.py— pipeline that walks the OpenPLZ REST API hierarchy for Germany, Austria, and Switzerland, paginatingLocalitiesunder each region. ODbL-1.0 licensed source — an exact match for this repo's licence.Three new contribution files:
contributions/postcodes/DE.json— 12,815 records, 2.5 MBcontributions/postcodes/AT.json— 18,722 records, 4.0 MBcontributions/postcodes/CH.json— 4,059 records, 840 KBTotal: 35,596 postcodes across DACH with 100%
state_idresolution.State resolution strategy
states.json, with umlaut normalisation. 100% (16/16 federal states match cleanly).LI deliberately omitted
contributions/postcodes/LI.jsonis already curated (#1401) with 13 high-quality 1:1 commune-to-code rows. OpenPLZ's per-code endpoint returns multiple sub-localities per code (e.g. Vaduz-Triesen, Vaduz-Schaan) that would muddy the existing clean mapping.Validation (zero errors across 35,596 records)
state_idresolvedpostal_code_regexstate_code↔state.iso2agreementLicense & attribution
source: "openplz"for programmatic attributionCumulative postcode coverage after this lands
Refs: #1039