Skip to main content

CKAN Tutorial

This functionality requires an experimental ckan plugin. Read More

Frictionless supports reading and writing CKAN datasets.

CLI
pip install frictionless[ckan]

Reading Data#

You can read a CKAN dataset:

from pprint import pprint
from frictionless import Package
package = Package.from_ckan('<base_url>', dataset_id='<dataset_id>', api_key='<api_key>')
pprint(package)
for resource in package.resources:
pprint(resource.read_rows())

Writing Data#

[NOTE] Timezone information is ignored for datetime and time types.

You can write a dataset to CKAN:

from frictionless import Package
package = Package('path/to/datapackage.json')
package.to_ckan('<base_url>', dataset_id='<dataset_id>', api_key='<api_key>')

Configuring Data#

There is a dialect to configure how Frictionless read and write files in this format. For example:

from frictionless import Resource
from frictionless.plugins.ckan import CkanDialect
dialect = CkanDialect(resource='resource', dataset='dataset', apikey='apikey')
resource = Resource('https://ckan-portal.com', format='ckan', dialect=dialect)

References:

Last updated on by roll