Skip to main content

The CKAN connector allows users to read and write data to/from CKAN servers.

Tabset

Read​

Recipe​

read:
- ckan:
host: https://data.example.com
dataset: my-dataset
file: example.csv
api_key: my_key

Function​

from wrangles.connectors import ckan
df = ckan.read(
host='https://data.example.com',
dataset='my-dataset',
file='example.csv',
api_key='my_key'
)

Parameters​

ParameterRequiredData TypeNotes
host✓strThe host name of the CKAN site. e.g. https://data.example.com
dataset✓strThe name of the dataset. This should be the url version e.g. my-dataset
file✓strThe name of the specific file within the dataset. e.g. example.csv
api_keystrAPI Key for the CKAN site
order_bystrUses SQL syntax to sort the input.
ifstrA condition that will determine whether the action runs or not as a whole.

Write​

Recipe​

write:
- ckan:
host: https://data.example.com
api_key: my_key
dataset: my-dataset
file: example.csv

Function​

from wrangles.connectors import ckan
ckan.write(
df,
host='https://data.example.com',
api_key='my_key',
dataset='my-dataset',
file='example.csv'
)

Parameters​

ParameterRequiredData TypeNotes
df✓DataFrameFunction only. DataFrame of contents to write to the database. Columns must match the target schema.
host✓strThe host name of the CKAN site. e.g. https://data.example.com
api_key✓strAPI Key for the CKAN site
dataset✓strThe name of the dataset. This should be the url version e.g. my-dataset
file✓strThe name of the specific file within the dataset. e.g. example.csv
columnslistSubset of the columns to be written. If not provided, all columns will be output.
not_columns✓strSubset of the columns to NOT be written. If not provided, all columns will be output.
where✓strFilter the data to only apply the wrangle to certain rows using an equivalent to a SQL where criteria, such as column1 = 123 OR column2 = 'abc'
where_paramsstrVariables to use in conjunctions with where. This allows the query to be parameterized. This uses sqlite syntax (? or :name)
order_bystrUses SQL syntax to sort the output.
ifstrA condition that will determine whether the action runs or not as a whole.