Spaces:
Sleeping
Sleeping
Commit
·
90a444c
1
Parent(s):
bb4867f
updated download button
Browse files
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 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
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 |
|