laverdes commited on
Commit
cbb2e1a
1 Parent(s): 275f86e

fix: download button

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -8,6 +8,12 @@ st.markdown("Users can load their time-series data and select a set of transform
8
  Go ahead and use the sidebar on the left to upload your data files in *.json* format and start exploring and transforming it!")
9
  col1, col2 = st.columns(2)
10
 
 
 
 
 
 
 
11
  file_names, file_bytes = [], []
12
  with st.sidebar:
13
  files = st.file_uploader("Load files", accept_multiple_files = True)
@@ -87,8 +93,16 @@ with col2:
87
  df_right[relative_key] = [[field_value - baseline_mean[i] for field_value in df_right[option[0]][i]] for i in range(len(df_right))]
88
  st.markdown("After adding calculated fields")
89
  st.dataframe(df_right)
90
- st.download_button('Download CSV', df_right.to_csv("myfile.csv"))
91
- st.info("Your data has been downloaded, you can visualize and detect outliers in the 'Plotting' and 'Detect Outliers' pages on the sidebar.")
 
 
 
 
 
 
 
 
92
 
93
  if not df_base.empty:
94
  st.warning("Consider running outlier detection to clean your data!", icon="⚠️")
 
8
  Go ahead and use the sidebar on the left to upload your data files in *.json* format and start exploring and transforming it!")
9
  col1, col2 = st.columns(2)
10
 
11
+
12
+ @st.experimental_memo
13
+ def convert_df(df):
14
+ return df.to_csv(index=False).encode('utf-8')
15
+
16
+
17
  file_names, file_bytes = [], []
18
  with st.sidebar:
19
  files = st.file_uploader("Load files", accept_multiple_files = True)
 
93
  df_right[relative_key] = [[field_value - baseline_mean[i] for field_value in df_right[option[0]][i]] for i in range(len(df_right))]
94
  st.markdown("After adding calculated fields")
95
  st.dataframe(df_right)
96
+ csv = convert_df(df_right)
97
+ downl = st.download_button(
98
+ "Press to Download CSV",
99
+ csv,
100
+ "file.csv",
101
+ "text/csv",
102
+ key='download-csv'
103
+ )
104
+ if downl:
105
+ st.info("Your data has been downloaded, you can visualize and detect outliers in the 'Plotting' and 'Detect Outliers' pages on the sidebar.")
106
 
107
  if not df_base.empty:
108
  st.warning("Consider running outlier detection to clean your data!", icon="⚠️")