Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unable to parse csv file in web2py break CSV parsing when dynamic upload is used #671

Closed
jvanbraekel opened this issue Oct 4, 2021 · 0 comments

Comments

@jvanbraekel
Copy link
Contributor

Hello,

The PR #654, actually break the CSV parsing, when it was working previously... Specifically, in case of dynamic upload in web2py : when the CSV file is uploaded trough the application before import into the database. TextIOWrapper is then already used to convert the binary stream into a string one the second usage in csv.reader raise an exception.

An example of usage in web2py controller typically looks like this : db.import_from_csv_file(TextIOWrapper(request.vars.file_selector.file,encoding='utf8'))

Removing TextIOWrapper from the call don't work, because pydal, 'object' and 'base' class are expecting string and not binary data. Consequently, all the parsing/format tests check for hard-coded string values ( for instance "TABLE' and not b"TABLE"), thus crash when binary data is used.

@jvanbraekel jvanbraekel changed the title Fix unable to parse csv file in web2py breaks CSV parsing when dynamyc upload is used Fix unable to parse csv file in web2py break CSV parsing when dynamic upload is used Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant