manika07 commited on
Commit
9d8c6bc
·
1 Parent(s): 29e8203

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -11
app.py CHANGED
@@ -85,14 +85,9 @@ if uploaded_file is not None:
85
  st.sidebar.header("Download Results")
86
  st.sidebar.text("Download the tagged results as a CSV file.")
87
 
88
- # Create download tab
89
- with st.sidebar:
90
- st.header("Download")
91
- if st.button("Download CSV file"):
92
- download_csv(df)
93
-
94
- def download_csv(df):
95
- """Downloads a CSV file from the given DataFrame."""
96
- b64_df = base64.b64encode(df.to_csv().encode()).decode()
97
- headers = {"Content-Disposition": "attachment; filename=data.csv"}
98
- return st.download_file(b64_df, "data.csv", headers=headers)
 
85
  st.sidebar.header("Download Results")
86
  st.sidebar.text("Download the tagged results as a CSV file.")
87
 
88
+ # Create a download button
89
+ if st.sidebar.button("Download"):
90
+ csv = df.to_csv(index=False)
91
+ b64 = base64.b64encode(csv.encode()).decode()
92
+ href = f'<a href="data:file/csv;base64,{b64}" download="results.csv">Download csv file</a>'
93
+ st.markdown(href, unsafe_allow_html=True)