After editing the dataframe, I want to copy the new edited_df into a file, so that I can use it later. But I am not clear if this is possible in streamlit?
here is my code.
import streamlit as st
import pandas as pd
data=st.sidebar.file_uploader("Upload your file", type=['xlsx'])
submit_button = st.form_submit_button(label='Submit')
if data is not None:
df=pd.read_excel(data, engine='openpyxl', index_col=None)
pd.DataFrame.reset_index(dd1, drop=True, inplace=True)
options = st.multiselect(
'What are the fields you want to display?',
['SN','CName','Hname','OS Version','Group','Site','Model','Risk','Risk Age','Detected Date','Severity','Impact Area','Impact Level','Category','Risk Triggered Date','Acknowledged','Risk ID','Details','Potential Impact','Mitigation','Corrective Action 1','Corrective Action 2','Has Fixit'])
if options ==:
st.write('You selected no fields')
st.write('You selected:', options)
edited_df = st.experimental_data_editor(dd2)
st.write("update the new filee")
Hi @raghava4u, thanks for the update. Unfortunately, most of your code is still being treated as plain text. To make it formatted as code, please put it in a code block by putting triple backticks ``` around it. Right now if I copy and paste your code to try it out it doesn’t work because when you pasted it as normal text, all of the quotes got converted to curly quotes. Pasting code within a code block is the only way to avoid your quotes and indentation being messed up that way.
@blackary i have updated the code block with code. and yes, my requirement is to load the data from excelfile, and add comments into some fields and save it back to a new excel file. ( later idea to push intoa sqqlite3 db).
but if you look at the code, when i save the edited_df into a new file, the added new informations are not updated/displayed in new excel file. hope I am clear with my question.
Just a quick observation: You have your data editor inside a form. As such, I would not expect it to return the edited result in real time. I would expect the value of edited_df to reflect whatever the state was when the form submit button was last clicked. I see that the button for saving your edited dataframe is separate from the form.
So, are you:
Editing the dataframe
Clicking the form submit button so the data editor updates its output
Clicking the update button (without any further edits that will get missed)