[ckan-dev] problem with import of latin character
David Read
david.read at okfn.org
Thu May 26 12:01:41 UTC 2011
2011/5/26 <p.romain at cg33.fr>:
>
> Hi,
>
> We wrote a script for the bulk import of our catalogues of data packages but
Your script looks basically fine.
> we can't import data with latin characters. Is there something to set in the
> python script that we are missing (encoding or something..)
The importer should support latin chacters fine. We have a test for
this. You could try importing our test spreadsheet using your script
and see if that works ok.
http://bitbucket.org/okfn/ckanext-importlib/src/default/ckanext/importlib/tests/
See samples directory and compare test_importer_full.xls and
test_importer_full.csv which are the same data in the two different
formats.
Excel files are unicode, and that's what we use internally too:
https://secure.simplistix.co.uk/svn/xlrd/trunk/xlrd/doc/xlrd.html
It might help us to see the exception too.
David
> Here is the script
>
> import types
> import tempfile
> import os
>
> from sqlalchemy.util import OrderedDict
> from pylons import config
>
> from ckanclient import CkanClient, CkanApiError
> import ckan.model as model
> from ckanext.importlib import importer
> from ckanext.importlib import loader
> from ckanext.importlib import spreadsheet_importer
> from ckanext.importlib.spreadsheet_importer import readonly_keys
>
> IMPORT_DIR = os.path.dirname(os.path.abspath(__file__))
> filepath = os.path.join(IMPORT_DIR, 'data') + '/cg33_import_data.xls'
>
> base_location = 'http://ckanserver:5010/api'
> ckanclient = CkanClient(
> base_location=base_location,
> api_key='0eef0148-8534-48ed-bbd7-23ce3d7a5314',
> is_verbose=True,
> )
> reader = spreadsheet_importer.SpreadsheetPackageImporter(buf=None,
> filepath=filepath)
> loader = loader.ReplaceByNameLoader(ckanclient)
> print loader.load_packages(reader.pkg_dict())
>
>
>
> Pascal
> __________________________________________________________________
>
> Ce message et toutes les pièces jointes sont confidentiels et établis à
> l'intention exclusive de ses destinataires. Ce message ne constitue pas un
> document officiel. Seuls les documents revêtus de la signature du Président
> du Conseil Général ou d'un de ses délégataires sont de nature à engager le
> Département.
> Toute utilisation ou diffusion non autorisée est interdite. Tout message
> électronique est susceptible d'altération et le Département de la Gironde
> décline toute responsabilité au titre de ce message s'il a été altéré,
> déformé, falsifié.
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
>
>
More information about the ckan-dev
mailing list