Created
May 12, 2015 21:48
-
-
Save snowch/fa1eb4ce0ce44c3fb1a4 to your computer and use it in GitHub Desktop.
Baltimore City Employee Salaries FY2014
This file contains hidden or 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
#!/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