Anyone know why you get:
EmptyDataError: No columns to parse from file
when i run:
if uploaded_file is not None:
df = pd.read_csv(uploaded_file)
Anyone know why you get:
EmptyDataError: No columns to parse from file
when i run:
if uploaded_file is not None:
df = pd.read_csv(uploaded_file)
Are you able to do read the csv you uploaded with pd.read_csv when the file is stored locally ? (ie. in a notebook for example). It could be that you uploaded a file that can’t be read with pandas. Keep an eye on this post, the user seems to have the same issue as you.
Locally it works perfectly. When I deploy the app to Heroku. The app builds, runs and even completes the upload of the csv file. I read the Stackoverflow thread you linked…Same same for me. May change the dependency back to streamlit 0.66 in requirements. But any subsequent operations on the file and it throws :
EmptyDataError: No columns to parse from file
Traceback:
File "/app/.heroku/python/lib/python3.6/site-packages/streamlit/script_runner.py", line 324, in _run_script
exec(code, module.__dict__)File "/app/myappV3.py", line 239, in <module>
main()File "/app/myappV3.py", line 197, in main
df,columns = upload_csv()File "/app/myappV3.py", line 174, in upload_csv
df = pd.read_csv(uploaded_file)File "/app/.heroku/python/lib/python3.6/site-packages/pandas/io/parsers.py", line 686, in read_csv
return _read(filepath_or_buffer, kwds)File "/app/.heroku/python/lib/python3.6/site-packages/pandas/io/parsers.py", line 452, in _read
parser = TextFileReader(fp_or_buf, **kwds)File "/app/.heroku/python/lib/python3.6/site-packages/pandas/io/parsers.py", line 936, in __init__
self._make_engine(self.engine)File "/app/.heroku/python/lib/python3.6/site-packages/pandas/io/parsers.py", line 1168, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)File "/app/.heroku/python/lib/python3.6/site-packages/pandas/io/parsers.py", line 1998, in __init__
self._reader = parsers.TextReader(src, **kwds)File "pandas/_libs/parsers.pyx", line 540, in pandas._libs.parsers.TextReader.__cinit__
Just so I’m clear, your app works locally with 0.68, but deploying to Heroku it only works with 0.66?
It’s likely that you need to reset your buffer with uploaded_file.seek(0)
.
Previously we were creating a new buffer for you each time we reran. To optimize, we are returning the same buffer on rerun. Unfortunately, this means that if you’ve already read the buffer, you’ll need to reset after. If you use .getValue()
, there’s no need to seek
. Unfortunately for file uploader pandas.read_csv
does a read()
which will require a buffer reset.
Probably worth adding this exact error message to our docs, to give it more visibility.
Ok thank you I will try to implement your suggestions.
Facing the same issue repeatedly
implemented all solutions given still facing the same error
Please provide proper solution
seek(0) works perfectly
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.