abdulllah01 commited on
Commit
9ead40f
·
verified ·
1 Parent(s): dc52166

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -5,6 +5,7 @@ from fuzzywuzzy import process
5
  import string
6
  from nltk.corpus import stopwords
7
  import nltk
 
8
 
9
  nltk.download('stopwords')
10
 
@@ -95,12 +96,16 @@ if st.button("Process"):
95
  st.write(f"{keyword}: {count}")
96
 
97
  # Save to Excel
98
- save_results = st.checkbox("Save results to Excel")
99
- if save_results:
100
- df = pd.DataFrame(list(results.items()), columns=["Keyword", "Count"])
101
- st.download_button(
102
- label="Download Results as Excel",
103
- data=df.to_excel(index=False, engine='openpyxl'),
104
- file_name="results.xlsx",
105
- mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
106
- )
 
 
 
 
 
5
  import string
6
  from nltk.corpus import stopwords
7
  import nltk
8
+ import io
9
 
10
  nltk.download('stopwords')
11
 
 
96
  st.write(f"{keyword}: {count}")
97
 
98
  # Save to Excel
99
+ st.subheader("Download Results")
100
+ df = pd.DataFrame(list(results.items()), columns=["Keyword", "Count"])
101
+ output = io.BytesIO()
102
+ with pd.ExcelWriter(output, engine='openpyxl') as writer:
103
+ df.to_excel(writer, index=False, sheet_name="Results")
104
+ output.seek(0)
105
+
106
+ st.download_button(
107
+ label="Download Results as Excel",
108
+ data=output,
109
+ file_name="results.xlsx",
110
+ mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
111
+ )