From 41c07d3935db6bdab40a4e3cc5408a2ccf979633 Mon Sep 17 00:00:00 2001 From: Pratham Soni Date: Mon, 17 Jun 2024 14:30:30 -0500 Subject: [PATCH] On page reload Interface 1 resets results to be empty --- streamlit/interface_1.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/streamlit/interface_1.py b/streamlit/interface_1.py index 71660c6..25666d5 100644 --- a/streamlit/interface_1.py +++ b/streamlit/interface_1.py @@ -31,6 +31,12 @@ st.set_page_config(layout = "wide") # add_vertical_space(15) # # st.write("Doczy") +#Update Dataframe to Empty Dataframe When Pipeline is Ran +def update_dataframe(): + new_df = pd.DataFrame(columns=['Contract Name', 'Unique Key','Pricing Before Carveouts' + , 'Contract Related', 'Provider', 'Timeline', 'Carveout Indicator', 'Carveout Methodology']) + st.session_state['dataframe'] = new_df + # AARETE LOGO x,y,z = st.columns([15,2,15]) with y: @@ -184,7 +190,11 @@ if st.button("Read the contracts from Path"): add_vertical_space(1) df2 = pd.read_csv('temp1.csv') -edited_df = st.data_editor(df2) +#Initialize Session State for Dataframe to Reset when Pipeline Run +if 'dataframe' not in st.session_state: + st.session_state['dataframe'] = df2 +edited_df = st.data_editor(st.session_state['dataframe']) + edited_df['REQUEST_USER'] = user_mail edited_df['LATEST_FLAG BOOLEAN'] = True @@ -254,6 +264,8 @@ with buttons[1]: if not st.session_state.contract_count == len(edited_df): st.error("Select at least one Group No. for every Contract") else: + #Resets the Data Editor with Blank Values + update_dataframe() with st.spinner('Running...'): # csv_buf = StringIO() # additional_info.to_csv(csv_buf, header=True, index=False)