I am using the lates version of Streamlit 0.84.0 and I still get this problem of not being able to clear the cache after file upload and with a new file uploaded my app still uses the previous one.
Please let me know if there is a way to solve this.
Here is my code:
# Read CSV -> outputs Pandas Dataframe def load_csv(ds): df_input = pd.DataFrame() df_input=pd.read_csv(ds) return df_input # CSV File uploader def file_upload(): FILE_TYPES = ["CSV"] file = st.file_uploader("Upload file", type=FILE_TYPES) show_file = st.empty() if not file: show_file.info("Please upload a file of type: " + ", ".join(FILE_TYPES)) return return file
file = file_upload() if file: if 'load_csv' in st.session_state: df=st.session_state.load_csv st.write(file.name + " " + "is loaded") else: df = load_csv(file) st.session_state.load_csv = df # Dataframe columns and types if file: st.write("Columns and their types:") col = column_types(df) st.write(col) # Show Dataframe st.text("Display uploaded dataframe") if st.checkbox("Show dataset"): st.dataframe(df)
And when a new file uploads even the dataset show button still shows the results from the previous uploaded dataset.
let me know if anyone have the same problem and could solve it