Last active
July 21, 2017 15:18
-
-
Save mheadd/117121092e82c537a599631542121d48 to your computer and use it in GitHub Desktop.
A simple script to pull down businesses by license type and display in a searchable HTML table.
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
##!/bin/bash | |
# License number (e.g., 3381). | |
LICENSE_TYPE=$1 | |
# The name of the file to populate with records. | |
FILE_NAME=$2 | |
echo "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" > $FILE_NAME | |
curl -s "http://services.phila.gov/PhillyApi/Data/v1.0/licenses?%24filter=substringof(%27$LICENSE_TYPE%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 --raw-output >> $FILE_NAME | |
csvtotable $FILE_NAME --serve |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example above uses an API from the City of Philadelphia's Department of Licenses & Inspections. This is an OData API that returns JSON.
Make the file executable:
chomd +x find-biz-by-license.sh
Execute thusly (for example, using registered pawn shops):
~$ ./find-biz-by-license.sh 3381 pawn_shops.csv