Importing a CSV file from the Database form fails

95 views
Skip to first unread message

Andrew Rogers

unread,
Mar 5, 2020, 4:07:27 AM3/5/20
to web2py-users
Hi

I exported a CSV file using the Import/Export > 'export as csv file' button found in the Database interface of web2py. That worked fine. 

I then modified the exported file slightly - just changed the IDs.

I then tried to import the modified file back into the table using the 'import' button in the same area. But it fails with:

<div>unable to parse csv file<pre>iterator should return strings, not bytes (did you open the file in text mode?)</pre></div> ×

What am i doing wrong?

Thanks
Andrew

VJ Sosa

unread,
May 3, 2020, 10:50:23 AM5/3/20
to web2py-users
Dear Andrew,

I had a similar issue when moved my web2py application from python2 to python3. 
Everything was working well until I tried to upload CVS files using the function included in the appadmin. It raised the same error as yours.

I could solve this  issue using the suggestion given by  tdean1991, here:

I hope that also works for you,
Regards,
Víctor.

Clemens

unread,
May 3, 2020, 10:54:50 AM5/3/20
to web2py-users
Have a look on how you open the file to be imported:

python2:
open(filename, 'rb')

python3:
open(str(filename), 'r', encoding='utf-8'))

Hope, it helps!

Regards
Clemens

AGRogers

unread,
May 3, 2020, 11:29:11 PM5/3/20
to web...@googlegroups.com
Thanks for the tips. I wrote an import to get in what i needed. But i will try this out when i need to do my next simple import.
Cheers
Andrew

--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/cd078f5a-6053-40ff-a1ff-c6241c3518d7%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages