2

I'm trying to create pandas dataframe from uploaded csv file without saving file. When I do df = pd.read_csv(request.file['file']) pandas read this as a file but EmptyDataError: No columns to parse from file is shown. But this file is loaded properly to dataframe from console. request.file['file'].stream doesn't work also.

  • I had the same problem but, it was solved by using FileStorage.stream. It points to a temporary copy of the file. See the documentation here: https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.FileStorage – Akalanka Weerasooriya May 13 '20 at 11:57

1 Answers1

2

If you are receiving your csv as a string try it using StringIO:

from io import StringIO
pd.read_csv(StringIO(request.file['file']))
zipa
  • 26,044
  • 6
  • 38
  • 55