I’ve been getting this error from file_uploader when I adjust a slider or do anything that reruns the app. I saw posts talking about using seek(0) on the file, but that didn’t seem to help. I upgraded to version 71, since it said that it was taking out the need to do a seek, but I’m still running into issues. Posted the error I’m seeing, and my code, any ideas would be great.
ValueError: I/O operation on closed file. Traceback: ``` File "/Users/x/miniconda3/envs/streamlit/lib/python3.8/site-packages/streamlit/script_runner.py", line 332, in _run_script exec(code, module.__dict__)File "/Users/x/x/x/x/x/My_Streamlit.py", line 349, in <module> main()File "/Users/x/x/x/x/x/x/My_Streamlit.py", line 22, in main uploaded_file = st.file_uploader("Select the impact data file you would like to analyze.", type='.csv')File "/Users/x/miniconda3/envs/streamlit/lib/python3.8/site-packages/streamlit/elements/file_uploader.py", line 122, in file_uploader if file.tell() > 0: ```
This the code from that I’m using:
uploaded_file = st.file_uploader("Select the impact data file you would like to analyze.", type='.csv') if uploaded_file: # Read in the file to a dataframe and find out what row the summary and raw data sections split at splitRow, dfFile, test_name = initial_read_data(uploaded_file) @st.cache def initial_read_data(aFile): test_name = aFile.name dfRead = pd.read_csv(aFile, skiprows=5, skipfooter=4, engine='python') foundRow = dfRead['Sample Name'].values.tolist().index("RAW DATA") return foundRow, dfRead, test_name