Issues/question regaring st.file_uploader


This might be a stupid question but Im new to python and new to streamlit.

Trying to make an app that would let the user select a local .tgz archive using the st.file_uploader. The file changes from use to use but the content will keep a strict format - I want the app to parse and display the information.

The 2nd-part I’ve figured out using pandas - my issue is with streamlit and the st.file_uploader - How do I interact with the object that is uploaded in a correct way - the object will as I said always be a .tgz archive with strict formatting.

The code looks like this at the moment - trying to extract the tgz using tarfile.

with sidebar:

    st.sidebar.subheader("Select a .tgz ")
    file = st.sidebar.file_uploader("Fileselector", type="tgz")

    if not file == None:
        tar =
        st.sidebar.write("No file selected")

Getting stuck with this error:
“TypeError: expected str, bytes or os.PathLike object, not UploadedFile”

Any ideas?

Thanks in advance.

Hi @Petter, welcome to the Streamlit community!

Please see the documentation for st.file_uploader here, specifically the examples section:

I would guess that does not know what you mean, but if you did would, as you’d be passing a BytesIO buffer to the open function.