Last active
December 23, 2015 22:49
-
-
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.
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
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 |
Could do the same thing for permits, violations, etc.
Could also set up a cron job to run daily and get a fresh list produced each day.
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
In this example, looking for registered pawn shops.
Assumes system where this is run has jq installed.
TODO: Convert to a proper shell script and allow input params (e.g., license_type_code) to be passed in.