To install ckanext-resourcecsv:
Activate your CKAN virtual environment, for example:
. /usr/lib/ckan/default/bin/activate
Install the ckanext-resourcecsv Python package into your virtual environment:
pip install ckanext-resourcecsv
- Add
resourcecsv
to theckan.plugins
setting in your CKAN config file (by default the config file is located at/etc/ckan/default/production.ini
). Restart CKAN. For example if you've deployed CKAN with Apache on Ubuntu:
sudo service apache2 reload
To install ckanext-resourcecsv for development, activate your CKAN virtualenv and do:
cd ckanext-resourcecsv
python setup.py develop
pip install -r dev-requirements.txt
Specify the schema file in the CKAN configuration:
## ResourceCSV plugin settings
ckanext.resourcecsv.schemas.infoplus = ckanext.resourcecsv:infoplus.json
{
"ATTRIBUT_DE": [2,6,9,11],
"ATTRIBUT_EN": [2,6,9,11],
"ATTRIBUT_FR": [2,6,9,11],
"ATTRIBUT_IT": [2,6,9,11],
"BAHNHOF": [5,7],
"BETRIEB_DE": [5,7],
"BETRIEB_EN": [5,7],
"BETRIEB_FR": [5,7],
"BETRIEB_IT": [5,7],
"BFKOORD": [8,20,29,35],
"BFKOORD_GEO": [8,19,29,35],
...
}
The keys are filenames to match. The values are lists with column numbers.
For each uploaded file, the extension will check the uploaded file's filename against the keys in the schema. If the key exists, the extension will * inject the delimiter ";" at the specified column in each line, replacing the character that's already there * save the the rewritten file to the /tmp folder * upload the file to the dataset, with a '.csv' extension
To run the tests, do:
nosetests --nologcapture --with-pylons=test.ini
To run the tests and produce a coverage report, first make sure you have coverage installed in your virtualenv (pip install coverage
) then run:
nosetests --nologcapture --with-pylons=test.ini --with-coverage --cover-package=ckanext.resourcecsv --cover-inclusive --cover-erase --cover-tests