Skip to content

Instantly share code, notes, and snippets.

@snowch
Created May 12, 2015 21:48
Show Gist options
  • Save snowch/fa1eb4ce0ce44c3fb1a4 to your computer and use it in GitHub Desktop.
Save snowch/fa1eb4ce0ce44c3fb1a4 to your computer and use it in GitHub Desktop.
Baltimore City Employee Salaries FY2014
#!/usr/bin/env python
import requests, json
CL_USERNAME = CHANGE_ME
CL_PASSWORD = CHANGE_ME
AUTH=(CL_USERNAME, CL_PASSWORD)
jsondata = requests.get('https://data.baltimorecity.gov/api/views/2j28-xzd7/rows.json?accessType=DOWNLOAD')
colnames = [colname['name'].strip() for colname in jsondata.json()['meta']['view']['columns']]
posturl='https://' + CL_USERNAME + '.cloudant.com/baltimorecity/_bulk_docs'
alldata = {'docs': [dict(zip(colnames, data)) for data in jsondata.json()['data']]}
resp = requests.post(posturl, auth=AUTH, data=json.dumps(alldata), headers=postheaders)
print resp.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment