Skip to content

Instantly share code, notes, and snippets.

@timwis timwis/
Created Dec 28, 2016

What would you like to do?
Get a list of OpenDataPhilly datasets that have resources hosted on Socrata
import csv
import sys
import requests
odp_packages_url = ''
odp_dataset_prefix = ''
socrata_keyword = '//'
response = requests.get(odp_packages_url)
response_data = response.json()
packages = response_data['result']['results']
socrata_packages = []
for package in packages:
basic_package = {
'metadata_created': package['metadata_created'],
'metadata_modified': package['metadata_modified'],
'title': package['title'],
'slug': package['name'],
'url': odp_dataset_prefix + package['name'],
'socrata_resources': [],
for resource in package['resources']:
if socrata_keyword in resource['url']:
resource_string = '({0}) {1}'.format(resource['format'], resource['url'])
if len(basic_package['socrata_resources']) > 0:
basic_package['socrata_resources'] = '\n'.join(basic_package['socrata_resources'])
fieldnames = ['title', 'slug', 'url', 'metadata_created', 'metadata_modified', 'socrata_resources']
writer = csv.DictWriter(sys.stdout, fieldnames=fieldnames)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.