I am using streamlit version v0.68 and currently working on CSV file for data analysis.
st.title('Report Analysis')
uploaded_file = st.file_uploader("Choose a file")
if uploaded_file is not None:
data = pd.read_csv(uploaded_file, low_memory=False)
st.write(data.shape)
First it works, but if I rerun the program in my localhost it gives me the error:
EmptyDataError: No columns to parse from file
Traceback:
File "D:\My Programs\Projects\ReportAnalysis\venv\lib\site-packages\streamlit\script_runner.py", line 324, in _run_script
exec(code, module.__dict__)
File "D:\My Programs\Projects\ReportAnalysis\epl\app.py", line 9, in <module>
data = pd.read_csv(uploaded_file, low_memory=False)
File "D:\My Programs\Projects\ReportAnalysis\venv\lib\site-packages\pandas\io\parsers.py", line 686, in read_csv
return _read(filepath_or_buffer, kwds)
File "D:\My Programs\Projects\ReportAnalysis\venv\lib\site-packages\pandas\io\parsers.py", line 452, in _read
parser = TextFileReader(fp_or_buf, **kwds)
File "D:\My Programs\Projects\ReportAnalysis\venv\lib\site-packages\pandas\io\parsers.py", line 946, in __init__
self._make_engine(self.engine)
File "D:\My Programs\Projects\ReportAnalysis\venv\lib\site-packages\pandas\io\parsers.py", line 1178, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "D:\My Programs\Projects\ReportAnalysis\venv\lib\site-packages\pandas\io\parsers.py", line 2008, in __init__
self._reader = parsers.TextReader(src, **kwds)
File "pandas\_libs\parsers.pyx", line 540, in pandas._libs.parsers.TextReader.__cinit__
How to handle this error?
How to resolve the error ‘EmptyDataError’:No column to parse from file while reading data into a Panda Dataframe. when empty data or header is encountered then this exception is thrown. Recheck quality of the input file you are reading. Your csv format is proper (remember sometimes comma create issues)
As a work-around, you can always go back to an older version, e.g. 0.66, using: pip install streamlit=0.66 Show activity on this post.
Since pd.read_csv depletes the buffer, the second time you call read_csv will return no rows. Adding a seek (0) to reset the buffer worked for me.
According to this post from the Streamlit community page, it is because they are returning the same buffer on the second time the app refreshes. Since pd.read_csv depletes the buffer, the second time you call read_csv will return no rows.
Adding a seek(0)
to reset the buffer worked for me.
e.g.
st.title('Report Analysis')
uploaded_file = st.file_uploader("Choose a file")
if uploaded_file is not None:
uploaded_file.seek(0)
data = pd.read_csv(uploaded_file, low_memory=False)
st.write(data.shape)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With