Petrock
A small, dependency-free geocoding and address-normalisation library for Python.
Petrock takes messy postal addresses and returns a normalised structure: street, house number, postcode, locality. It ships with rule sets for eleven European countries and does not call any remote service — everything runs locally against a compiled rule table of about 4 MB.
# install pip install petrock # normalise a single address from petrock import parse addr = parse("kralovska 12/4, praha 6", country="cz") print(addr.street, addr.number, addr.postcode)
Why not an API?
Address normalisation is usually the first step of a longer pipeline, often inside a batch job with millions of rows. Round-tripping every row through a network service is slow, costs money and drags a privacy question into what should be a pure function. Petrock keeps it local and deterministic: same input, same output, same version — forever.
What it does not do
- No latitude/longitude lookup. Petrock parses and normalises, it does not geocode to coordinates.
- No fuzzy matching against a delivery-point database. If the street does not exist, Petrock will still happily normalise it.
- No validation of whether a building number is real.
Looking for coordinates? Pair Petrock with any tile-server geocoder —
normalising first typically lifts hit rates by 15–20 % on user-entered data.
Supported countries
| Code | Country | Rule set | Coverage |
|---|---|---|---|
cz | Czechia | full | street, orientation no., postcode, district |
sk | Slovakia | full | street, number, postcode |
pl | Poland | full | street, number, postcode, voivodeship |
de | Germany | full | street, number, postcode, city |
at | Austria | full | street, number, postcode |
nl | Netherlands | full | street, number, suffix, postcode |
fr | France | partial | street, number, postcode (no CEDEX) |
hu, si, hr, ro | — | partial | street, postcode |