Working With UK Postcodes

postmanpat

I was recently working on a project which needed to match a user with a county based on their (UK) postcode. In the end searched over Wikipedia and made extensive use of Google to come up with a small table which matches the postcode prefix with the postal town, county, and region.

You can find a tab-separated file with this data here:

https://www.versionshelf.com/svn/omniwiki/code/users/adam/public/blog/trunk/postcode-table/postcodes.tsv

I hope this saves someone some time in the future. It only gives you accuracy down to the county level as the towns listed are the postal towns, which I assume are the local Royal Mail delivery hubs, and hence the user will not necessarily live there. I have included Guernsey, Jersey and the Isle of Man. However, overseas territories are not included (but you can find a list here).

Further Detail

If your application needs to map post codes to actual addresses then you will need to purchase the PAF File from the Royal Mail. Prices from this start from around the £100 mark, but for a web application you will probably be paying in the region of a few £1000.

For those of you in the US you may find US Postal Service Address Information Systems website useful.

No comments yet

Leave a reply