Python module for managing badly formatted UK postcode data.
The function takes a postcode in any format, and if it is a valid UK postcode returns it in the propert format, with the additional information of Longitude, Latitude, and London Borough (if applicable).
Now available to install via pypi:
pip install -U postcodez
The installation includes ~39Mb of files with the valid UK postcode data.
postcodez("n146bb")
Returns:
{"latitude": 51.638471184099998,
"london_borough": "Enfield",
"longitude": -0.117084777613,
"postcode_IN": "n146bb",
"postcode_OUT": "N14 6BB"}
postcodez("s11aa")
Returns:
{"latitude": 53.381549394899999,
"london_borough": "",
"longitude": -1.4642950000000001,
"postcode_IN": "s11aa",
"postcode_OUT": "S1 1AA"}
postcodez("not a postcode")
Returns:
{"latitude": "",
"london_borough": "",
"longitude": "",
"postcode_IN": "not a postcode",
"postcode_OUT": ""}