Example #1
0
def harvesting(url):
    catalog = dcat_to_utf8_dict(url)
    for dcat_dataset in catalog.get('dataset', []):
        ckan_dataset = converters.dcat_to_ckan(dcat_dataset)
        ckan_dataset['name'] = munge.munge_title_to_name(ckan_dataset['title'])
        ckan_dataset['state'] = 'active'
        upsert_dataset(remote, ckan_dataset)
Example #2
0
def package_to_dcat(package):
    return converters.ckan_to_dcat(package)


# pkg = ckanops.get_package('ciclones')
# print pkg
# print package_to_dcat(pkg)

# print 'Datasets'
# print list_datasets()
# print 'Groups'
# print list_groups()

catalog = ckanops.dcat_to_utf8_dict("http://adela.datos.gob.mx/sedesol/catalogo.json")
print catalog.get('title')

for dataset in catalog.get('dataset', []):
    d = converters.dcat_to_ckan(dataset)
    d['name'] = munge.munge_title_to_name(d['title'])
    print "Creating dataset '%s'" % d['title'], "with %d resources" % len(d['resources'])
    print "Name: %s" % d['name']
    print "Org: %s" % d['owner_org']
    new_dataset = ckanops.upsert_dataset(demo, d)
    if new_dataset:
        print 'Dataset upserted'
    else:
        print 'Something went wrong'