Fixing Postcodes
Published 16 years, 1 week pastIn case anyone’s interested, I finally updated the ZIP archive of all the countries and postcodes from the 2008 ALA survey. The two files are sorted like before, but this time leading-zero postcodes haven’t had their leading zeroes stripped by Excel. Oh, Excel.
I have learned way more about Excel’s “helpful” handling of CSV and text imports than I ever wanted to know. The basic drill is, if you want to open a CSV or text file but don’t want Excel to be “helpful”, don’t drop the file onto Excel or double-click the file icon. No no! That would be too easy.
Instead, launch Excel, select “File > Open”, and then select the CSV or text file you want to open in the file browser. Go through the Text Import Wizard carefully:
- Tell Excel that the file is delimited on the first screen. (Or, if it isn’t, then don’t. I bet it is, though.)
- Tell Excel what delimiter you’re using on the second screen.
- Then—this is the crucial bit—on the third Wizard screen, select the columns you don’t want Excel to “help” you with and set them to “Text”. Be careful about setting all the columns as “Text”, though: if you have non-ASCII characters, Excel will “helpfully” replace their contents with octothorpes when you try to export the data later. Such “help”! It’s so “helpful”!
Yay! An open file where the data is all in its original state!
Now you can save the file as an Excel workbook and it should (but please note my use of the word should) leave your data alone. Ditto if you do “Save As…” to export to CSV or text again, which you might do if you run some calculations and want to capture the result in a basic, portable format. But remember! If you ever want to open those CSV/text files in Excel, you can’t just open them. You have to go through the whole text-import process again.
So the survey files now contain actual useful data, especially for countries where postcodes can start with zeroes. (Which is a lot of them.) The files also have the usual bits of abuse that come along with daring to ask people to supply optional information, because I didn’t even try to filter that stuff out. So, you know, naughty words ahead.
In part, I’m posting this to leave a record for anyone else who runs into the same problems I had, and also to remind myself of what has to be done next year. Also to provide a heads-up to anyone who’d like to grab the fixed-up data and do fun mapping stuff with it, as did some commenters on the previous post.