I want to control the state of the file uploader

Hi all!

Loving working with streamlit but one area that I dont seem to be getting a straight answer from is when I want to manage the state of the file uploader widget. Currently the minute, I use the file uploader to upload a file, it instantly executes the next block of code.

I dont want that block of code to be executed unless and until a button that gives the go-ahead is clicked. To make things clearer, I am working on a tool that parses a type of work document. When I upload this file, it instantly starts the analysis. What I want to do is that after the file has been uploaded, I want the analysis to start only after I click the start button. Is it possible to do state management of this sort on streamlit?


Can you put your code that parses the document in a button-call?

# upload code is here...

if st.button("Analyze this!"):
    # do your analysis here...this is not run until the button is pressed

Thank you! That worked for me!