manika07 commited on
Commit
998a063
·
1 Parent(s): 276552d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -84,9 +84,8 @@ if uploaded_file is not None:
84
  st.sidebar.header("Download Results")
85
  st.sidebar.text("Download the tagged results as a CSV file.")
86
 
87
- # Create a download button
88
- if st.sidebar.button("Download"):
89
- csv = df.to_csv(index=False)
90
- b64 = base64.b64encode(csv.encode()).decode()
91
  headers = {"Content-Disposition": "attachment; filename=data.csv"}
92
- st.download_file(b64, "data.csv", headers=headers)
 
84
  st.sidebar.header("Download Results")
85
  st.sidebar.text("Download the tagged results as a CSV file.")
86
 
87
+ def download_csv(df):
88
+ """Downloads a CSV file from the given DataFrame."""
89
+ b64_df = base64.b64encode(df.to_csv().encode()).decode()
 
90
  headers = {"Content-Disposition": "attachment; filename=data.csv"}
91
+ return st.download_file(b64_df, "data.csv", headers=headers)