Skip to content

Instantly share code, notes, and snippets.

@mheadd
Created April 22, 2014 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mheadd/11191109 to your computer and use it in GitHub Desktop.
Save mheadd/11191109 to your computer and use it in GitHub Desktop.
Get the top 100 NYC bike share riders from July, 2013.
curl -s "http://www.civicdata.com/api/action/datastore_search_sql?sql=SELECT%20*%20from%20%229dd48bd2-fa77-43bb-a433-1227b3a17623%22%20ORDER%20BY%20tripduration%20DESC%20LIMIT%20100" \
| sed 's/birth year/birth_year/g;s/start station name/start_station_name/g;s/end station name/end_station_name/g' \
| jq .result.records[] \
| jq '[.tripduration, .birth_year, .gender, .start_station_name, .end_station_name]' \
| jq @csv \
| sed 's/\\//g;s/""/"/g'
@mheadd
Copy link
Author

mheadd commented Apr 22, 2014

To run the above, you'll need to install jq.

http://stedolan.github.io/jq/

@mheadd
Copy link
Author

mheadd commented Apr 22, 2014

Redirect the output of the above recipe to a new file. Just append with

>> my-new-file.csv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment