Skip to content

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

@jvanbraekel

Description

@jvanbraekel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions