I opened an issue about this until I can verify the problem:
https://code.google.com/p/web2py/issues/detail?id=1585&thanks=1585&ts=1373793319

On Wednesday, 10 July 2013 16:40:59 UTC-5, Wes Hall wrote:
>
> After using import_from_csv_file(), additional quotes are showing up in 
> the db.
>
> Should I be using some different quoting in export_to_csv_file() or is 
> this an inherent problem with specifying filter_out in in the model, or am 
> I completely off the mark?
>
> Exporting db = 2.4.6
> Importing db = 2.5.1
>
> Table definition
> db.define_table('evaluation',
>     Field('form', type='text',
>           label=T('Evaluation form')),
>     Field('results', type='text',
>           label=T('JSON results')),
>     auth.signature,
>     format='%(form)s',
>     migrate=settings.migrate)
>
> db.evaluation.results.filter_in = lambda obj, dumps=dumps: dumps(obj)
> db.evaluation.results.filter_out = lambda txt, loads=loads: loads(txt)
>
> Export
> db.export_to_csv_file(open('test.csv', 'w'))
>
> (Excerpt from test.csv)
> 89,se2,"{u'name': u'Good User', u'answers': {u'q1': u'5', u'comment1': 
> u""This answer should've had an apostrophe.""}, u'email': 
> u'[email protected]<javascript:>
> '}",<auth fields>
>
> Import
> db.import_from_csv_file(open('test.csv', 'r'))
>
> MySQL row.results from within current application on original and new db
> {"name": "Good User", "answers": {"q1": "5", "comment1": "This answer 
> should've had an apostrophe."}, "email": "[email protected] <javascript:>"}
>
> MySQL row.results from import on new db (note the new enclosing double 
> quotes)
> "{u'name': u'Good User', u'answers': {u'q1': u'5', u'comment1': u\"This 
> answer should've had an apostrophe.\"}, u'email': u'[email protected]<javascript:>
> '}"
>
> This all leads to the following error:
>
> evaluation.results['name']),
> TypeError: string indices must be integers
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to