I have been having a similar problem with importing from csv file and the same solution works.
db.import_from_csv_file(open(path, 'r', encoding='utf-8', newline=''))Enter code here... On Saturday, 2 March 2019 00:53:29 UTC+1, jim kaubisch wrote: > > been looking around some more. turns out this is a duplicate of this open > item - https://github.com/web2py/web2py/issues/2013 > > Have looked more closely at the 3.x docs for csv and open as well as the > code for export_to_csv_file in pydal. > > - the csv docs say 'w' only as Leonel suggested (not surprising), and say > to specify "newline = ''. > - adding the encoding as suggested by Dave results in > > with open(session.db_backup_name, 'w', encoding='utf-8', newline='') > as backup_file: > > which results in - SUCCESS at least so it seems. The claim is that the > backup is successful. I haven't yet tried to restore the saved backup > > On Friday, March 1, 2019 at 1:41:25 PM UTC-8, Dave S wrote: >> >> >> >> On Friday, March 1, 2019 at 12:43:21 PM UTC-8, jim kaubisch wrote: >>> >>> Thanks, Leonel, >>> >>> In a different app (not web2py) I hit this issue pickle and the change >>> you suggest solved the problem >>> Unfortunately, in the web2py and db.export_to_csv_file context, when I >>> make the change you suggest, the error message just changes to >>> >>> 01/Mar/2019-12:32:27: INFO : backups : 303 | backing >>> db up as >>> "applications/MFMCurrAssetMgr/private/_backups/bup_010319_123226/MFMCurrAssetMgr-db.csv" >>> 01/Mar/2019-12:32:27: WARNING : backups : 309 | - db >>> backup Failed: exception: "'ascii' codec can't encode character '\u2019' in >>> position 12: ordinal not in range(128)" >>> >> >> >> You probably need to specify an encoding in the open(), look at >> <URL:https://docs.python.org/3/library/functions.html#open> >> >> (which is also where the 'wb' -> 'w' is really explained) >> >> /dps >> >> >>> >>> On Friday, March 1, 2019 at 11:43:26 AM UTC-8, Leonel Câmara wrote: >>>> >>>> You actually have to open it using only 'w' instead of 'wb' in python 3 >>>> so change it to: >>>> >>>> with open(session.db_backup_name, 'w', newline=''): >>>> >>>> See: >>>> https://docs.python.org/3/library/csv.html?highlight=csv#csv.writer >>>> >>>> >>>> -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.