hacpdsae2023 commited on
Commit
90a444c
·
1 Parent(s): bb4867f

updated download button

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -48,12 +48,17 @@ if uploaded_file1 is not None and uploaded_file2 is not None:
48
 
49
  st.write(df1)
50
 
 
 
 
 
 
 
51
  st.download_button(
52
- "Press to Download",
53
- df1,
54
- "output_file.csv",
55
- "text/csv",
56
- key='download-csv'
57
  )
58
 
59
 
 
48
 
49
  st.write(df1)
50
 
51
+ @st.cache
52
+ def convert_df_to_csv(df):
53
+ # IMPORTANT: Cache the conversion to prevent computation on every rerun
54
+ return df.to_csv().encode('utf-8')
55
+
56
+
57
  st.download_button(
58
+ label="Download data as CSV",
59
+ data=convert_df_to_csv(df1),
60
+ file_name='output.csv',
61
+ mime='text/csv',
 
62
  )
63
 
64