Last active
August 29, 2015 14:13
-
-
Save evz/e2653e316660a516b47d to your computer and use it in GitHub Desktop.
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
MAKEFLAGS += --warn-undefined-variables | |
SHELL := /bin/bash | |
.SHELLFLAGS := -eu -o pipefail | |
.DEFAULT_GOAL := all | |
.DELETE_ON_ERROR: | |
.SUFFIXES: |
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
include config.mk | |
%.zip: | |
@wget -O $@ http://cdo.ncdc.noaa.gov/qclcd_ascii/QCLCD$(basename $@).zip | |
touch $@ | |
%.csv: %.zip | |
@unzip -p $< $(basename $<)daily.txt | \ | |
tail +2 > $(basename $<).csv | |
weather.csv: 201401.csv 201402.csv | |
@cat $^ | \ | |
grep "^94846" | \ | |
cut -d, -f 2,3,5,7,25,29,31 | \ | |
sort -t',' > $@ | |
raw_potholes.csv: | |
@wget -O $@ \ | |
https://data.cityofchicago.org/api/views/7as2-ds3y/rows.csv?accessType=DOWNLOAD | |
@touch $@ | |
potholes.csv: raw_potholes.csv | |
@grep "^01/[0-9][0-9]/2014\|^02/[0-9][0-9]/2014" $< | \ | |
sed -E 's,([0-9]{2})/([0-9]{2})/([0-9]{4}),\3\1\2,g' | \ | |
cut -d, -f 1,2,3,4,6,7,8 | \ | |
sort -t',' > $@ | |
potholes_weather.csv: potholes.csv weather.csv | |
@join -t, -1 1 -2 1 $^ | \ | |
(echo "create_date,status,complete_date,request_number,current_activity,most_recent_action,potholes_filled_on_block,max_temp,min_temp,avg_temp,snow_depth,snowfall,total_precip"; cat) > $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment