On Tuesday, March 31, 2020 at 2:02:29 AM UTC-7, aabelyakov wrote:
>
> When importing data (russian characters) from a .csv-file into a table, an
> error occurs:
> <class 'UnicodeDecodeError'> 'ascii' codec can't decode byte 0xd0 in
> position 65: ordinal not in range(128).
>
When you get this error, are you using appadmin to do the import? It
appears appadmin doesn't specify the encoding, so defaults to ASCII. In
2.18.5 that's line 177
of [...]\web2py\applications\admin\controllers\appadmin.py.
I'm not sure what the best way is to fix this, but it would be appropriate
to file a bug report.
> Standalone PyDAL works fine!
>
> =============================================================================
> import locale
> print('locale.getpreferredencoding(False) =',
> locale.getpreferredencoding(False))
>
> db.import_from_csv_file(
> open('applications/upoweron/databases/csv/all.csv'),
> restore=True,
> encoding="utf-8",
> )
>
> db.commit()
>
> =============================================================================
> Result:
> locale.getpreferredencoding(False) = ANSI_X3.4-1968
>
See, you specified the encoding there.
/dps
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/00bf872f-5f3c-4cf9-af31-88c98cb13299%40googlegroups.com.