Spaces:
Sleeping
Sleeping
rushidarge
commited on
Commit
·
570bdfc
1
Parent(s):
24d48f2
Update app.py
Browse files
app.py
CHANGED
@@ -19,6 +19,25 @@ st.title("Text Classification and Excel Processing App")
|
|
19 |
# File upload for Excel file
|
20 |
uploaded_file = st.file_uploader("Upload an Excel file", type=["xlsx"])
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
def pre_processing(data_frame):
|
23 |
|
24 |
# Lowercase all characters
|
@@ -117,8 +136,9 @@ if uploaded_file is not None:
|
|
117 |
|
118 |
st.dataframe(excel_data) # Display the processed data
|
119 |
|
120 |
-
|
121 |
-
|
|
|
122 |
|
123 |
|
124 |
# Create a new Excel file with the processed data
|
|
|
19 |
# File upload for Excel file
|
20 |
uploaded_file = st.file_uploader("Upload an Excel file", type=["xlsx"])
|
21 |
|
22 |
+
|
23 |
+
import base64
|
24 |
+
|
25 |
+
def get_binary_file_downloader_link(file_data, file_name, link_text):
|
26 |
+
"""
|
27 |
+
Generates a link to download a file.
|
28 |
+
|
29 |
+
Parameters:
|
30 |
+
- file_data: The data you want to make available for download.
|
31 |
+
- file_name: The name of the file when downloaded.
|
32 |
+
- link_text: The text to display for the download link.
|
33 |
+
|
34 |
+
Returns:
|
35 |
+
- A Streamlit markdown link for downloading the file.
|
36 |
+
"""
|
37 |
+
b64 = base64.b64encode(file_data.to_excel(index=False, engine='xlsxwriter')).decode()
|
38 |
+
href = f'<a href="data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,{b64}" download="{file_name}">{link_text}</a>'
|
39 |
+
return href
|
40 |
+
|
41 |
def pre_processing(data_frame):
|
42 |
|
43 |
# Lowercase all characters
|
|
|
136 |
|
137 |
st.dataframe(excel_data) # Display the processed data
|
138 |
|
139 |
+
|
140 |
+
link = get_binary_file_downloader_link(excel_data, 'my_processed_file.xlsx', 'Download Processed Data')
|
141 |
+
st.markdown(link, unsafe_allow_html=True)
|
142 |
|
143 |
|
144 |
# Create a new Excel file with the processed data
|