Skip to content

Instantly share code, notes, and snippets.

@cquest
Created June 29, 2015 12:58
Show Gist options
  • Save cquest/3fe739e2932008dac949 to your computer and use it in GitHub Desktop.
Save cquest/3fe739e2932008dac949 to your computer and use it in GitHub Desktop.
shell script to extract vote counts by location into CSV file from okfnindex2015 voting
# get votes from the map (curl)
# extract the lines containing values and reformat as csv (grep, sed)
echo "lat,lon,votes,location,country" > votes.csv
curl 'http://allourideas.org/globalopendataindex15/voter_map?type=votes' \
| grep "data.setValue" votes.html \
| sed 's/.*data.setValue([0-9]*, //;s/);//;s/, /,/' \
| sed 'N;s/\n[1-3]//' | sed 'N;s/\n[1-3]//' \
| sed 's/, \(..\)"$/",\1/;s/ ,"/,"/;s/^0,//' \
>> votes.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment