Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@chadmiller
Last active May 4, 2016 20:33
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 chadmiller/15b2e22539f557fed8ef44af7620894a to your computer and use it in GitHub Desktop.
Save chadmiller/15b2e22539f557fed8ef44af7620894a to your computer and use it in GitHub Desktop.
Orange County business licenses
#!/usr/bin/make -f
demo: orange-county-business-licenses.sqlite3
sqlite3 $< "select count(*) g, description from business_licenses group by description order by g, description;"
orange-county-business-licenses.sqlite3:
sqlite3 $@ "create table business_licenses (category int not null, account text, businessname text, streetaddress text, citystatezip text, unknown1 int, unknown2 int, unknown3 int, owner text, description text, phonenumber text, licensuredate text);"
set -u; seq 220 |while read weeksago; do wget -nv -O - $$(date +"https://www.octaxcol.com/Octc/Downloads/LocalBusinessTax/Data/%Y-%m-%d.zip" --date "$$weeksago weeks ago Friday") |funzip |sed -e 1d |awk -F, 'BEGIN { OFS=FS } { if ($$11 == "000-000-0000") { $$11=""; } print }' |sqlite3 -bail -stats -cmd '.separator ","' $@ '.import /dev/stdin business_licenses'; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment