V0.71.0 - file_uploader : I/O operation on closed file

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

Hi @pdxnick, thanks for reporting this! I’ve been taking a look and have been able to reproduce very intermittently with your code. I’m still trying to get this to reproduce consistently. Do you get this error on each rerun or intermittently? Also, could you share the file you are using or alternatively what the size of your file is?

We’ll look into adding better error handling but I would love to get to the root cause of this issue. We’ve also reopened this GH issue to track the work