Skip to content Skip to sidebar Skip to footer

Opening Csv File In Python: Builtins. Attributeerror Attributeerror: '_io.bytesio' Object Has No Attribute 'file'

further to my earlier question, on how to open an csv file in Python, I am still not successful in doing so and going from error to error. My Python code is as follows: @app.route

Solution 1:

io.TextIOWrapper takes a io.BytesIO object all right.

You're (almost) passing it, except that you're adding a .file (why??), which is not a field of the io.BytesIO class (request.files['portfolios'] is a io.BytesIO object already)

Just do:

csvfile = TextIOWrapper(request.files['portfolios'], encoding=request.encoding)

Post a Comment for "Opening Csv File In Python: Builtins. Attributeerror Attributeerror: '_io.bytesio' Object Has No Attribute 'file'"