display table reversed; added download options; always write hdf5
This commit is contained in:
37
stand.py
37
stand.py
@ -5,6 +5,7 @@ import hacks
|
|||||||
|
|
||||||
from restapi import restapi
|
from restapi import restapi
|
||||||
from utils.st_utils import get_session_id, rerun
|
from utils.st_utils import get_session_id, rerun
|
||||||
|
from utils.df_utils import to_excel_binary
|
||||||
|
|
||||||
|
|
||||||
st.set_page_config(layout="wide", page_icon="icon.png")
|
st.set_page_config(layout="wide", page_icon="icon.png")
|
||||||
@ -20,8 +21,35 @@ df = restapi.data
|
|||||||
print(">>> start of streamlit run")
|
print(">>> start of streamlit run")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
showing_downloads = st.session_state.get("showing_downloads", False)
|
||||||
|
|
||||||
|
col1, col2, col3, col4 = st.columns([1, 1, 1, 1])
|
||||||
|
with col1:
|
||||||
|
if st.button("Downloads") and not showing_downloads:
|
||||||
|
st.session_state.showing_downloads = True
|
||||||
|
|
||||||
|
with col2:
|
||||||
|
with open("output.h5", "rb") as f:
|
||||||
|
st.download_button("Download hdf5", f, file_name="output.h5")
|
||||||
|
|
||||||
|
with col3:
|
||||||
|
xlsx = to_excel_binary(df)
|
||||||
|
st.download_button("Download xlsx", xlsx, file_name="output.xlsx")
|
||||||
|
|
||||||
|
with col4:
|
||||||
|
csv = df.to_csv()
|
||||||
|
st.download_button("Download csv", csv, file_name="output.csv")
|
||||||
|
|
||||||
|
# st.stop()
|
||||||
|
|
||||||
|
else:
|
||||||
|
st.session_state.showing_downloads = False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
response = AgGrid(
|
response = AgGrid(
|
||||||
df,
|
df[::-1],
|
||||||
|
|
||||||
filter=True,
|
filter=True,
|
||||||
editable=True,
|
editable=True,
|
||||||
@ -37,6 +65,7 @@ response = AgGrid(
|
|||||||
|
|
||||||
|
|
||||||
new_df = response.get("data")#, df)
|
new_df = response.get("data")#, df)
|
||||||
|
new_df = new_df[::-1]
|
||||||
if not new_df.equals(df) and not changed:
|
if not new_df.equals(df) and not changed:
|
||||||
restapi.data = new_df
|
restapi.data = new_df
|
||||||
# print("old:")
|
# print("old:")
|
||||||
@ -49,6 +78,12 @@ if not new_df.equals(df) and not changed:
|
|||||||
#st.dataframe(df.astype(str))
|
#st.dataframe(df.astype(str))
|
||||||
#st.dataframe(new_df.astype(str))
|
#st.dataframe(new_df.astype(str))
|
||||||
|
|
||||||
|
if not new_df.empty:
|
||||||
|
# new_df.to_excel("output.xlsx")
|
||||||
|
new_df.to_hdf("output.h5", key="stand")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print(">>> end of streamlit run")
|
print(">>> end of streamlit run")
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user