Created
November 28, 2014 13:37
-
-
Save samuelleach/7ba0057db327960a1c1c to your computer and use it in GitHub Desktop.
Process Doogal UK postcode data into a postcode, lon, lat file
This file contains 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
# Doogal downloads: | |
DOOGAL_SITE=http://www.doogal.co.uk/files/ | |
DOOGAL_DATADIR=data_raw/doogal | |
all: $(DOOGAL_DATADIR)/postcodes_cut.csv | |
# PURPOSE: Create directory structure | |
setup: | |
mkdir -p data_raw data_intermediate data_deploy log | |
# 1 - PURPOSE: Download Doogal zipped postcode lookup file (56MB) | |
$(DOOGAL_DATADIR)/postcodes.zip: | |
mkdir -p $(dir $@) | |
wget $(DOOGAL_SITE)/$(notdir $@) -O $@.download && mv $@.download $@ | |
touch $@ | |
# 2 - PURPOSE: Unzip Doogal postcode lookup file | |
$(DOOGAL_DATADIR)/postcodes.csv: $(DOOGAL_DATADIR)/postcodes.zip | |
unzip -u $< -d $(dir $@) | |
touch $@ | |
# 3 - PURPOSE: Convert Doogal file to utf8 | |
$(DOOGAL_DATADIR)/postcodes_utf8.csv: $(DOOGAL_DATADIR)/postcodes.csv | |
iconv -c -t UTF-8 $< > $@ || true | |
# 4 - PURPOSE: Cut required columns from Doogal postcode file (68MB file) | |
$(DOOGAL_DATADIR)/postcodes_cut.csv: $(DOOGAL_DATADIR)/postcodes_utf8.csv | |
mkdir -p $(dir $@) | |
$(CSVKITROOT)csvcut -c Postcode,Latitude,Longitude $< > $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment