Skip to content

Instantly share code, notes, and snippets.

@mheadd
Last active December 23, 2015 22:49
Show Gist options
  • Save mheadd/6705590 to your computer and use it in GitHub Desktop.
Save mheadd/6705590 to your computer and use it in GitHub Desktop.
Unix command-line magic for fetching list of L&I licensed entities and saving to a simple CSV file.
curl -s "http://services.phila.gov/PhillyApi/Data/v1.0/licenses?%24filter=substringof(%273381%27,license_type_code)%20eq%20true&%24expand=locations&%24format=json" \
| jq .d.results[] \
| jq '[.pri_contact_last_name, .pri_contact_first_name, .pri_contact_company_name, .pri_contact_address1, .pri_contact_city, .pri_contact_state, .pri_contact_zip, .license_number, .license_type_name, .license_type_code]' \
| jq @csv \
| sed 's/\\//g;s/""/"/g' \
> filename.csv
@dgeske
Copy link

dgeske commented Jun 5, 2014

Nice job, this helped me along with my task. Thanks!

One suggested simplification: replace jq @csv | sed 's/\\//g;s/""/"/g' with jq '@csv' --raw-output

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