Spaces:
Sleeping
Sleeping
Commit
·
bb745aa
1
Parent(s):
7cdc6d9
Update app.py
Browse files
app.py
CHANGED
@@ -216,6 +216,11 @@ def create_download_link(data, filename):
|
|
216 |
b64 = base64.b64encode(csv_data.getvalue().encode()).decode()
|
217 |
return f'<a href="data:file/csv;base64,{b64}" download="{filename}">{filename}</a>'
|
218 |
|
|
|
|
|
|
|
|
|
|
|
219 |
responses_data = []
|
220 |
edited_responses_data = []
|
221 |
|
@@ -231,8 +236,18 @@ for i in range(row_count):
|
|
231 |
responses_data.append(response)
|
232 |
edited_responses_data.append(followup_response)
|
233 |
|
234 |
-
|
235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
|
237 |
-
|
238 |
-
st.markdown(
|
|
|
|
216 |
b64 = base64.b64encode(csv_data.getvalue().encode()).decode()
|
217 |
return f'<a href="data:file/csv;base64,{b64}" download="{filename}">{filename}</a>'
|
218 |
|
219 |
+
def create_download_link_txt(data, filename):
|
220 |
+
txt_data = "\n".join(data)
|
221 |
+
b64 = base64.b64encode(txt_data.encode()).decode()
|
222 |
+
return f'<a href="data:file/txt;base64,{b64}" download="{filename}">{filename}</a>'
|
223 |
+
|
224 |
responses_data = []
|
225 |
edited_responses_data = []
|
226 |
|
|
|
236 |
responses_data.append(response)
|
237 |
edited_responses_data.append(followup_response)
|
238 |
|
239 |
+
# Create download links for CSV files
|
240 |
+
download_responses_link_csv = create_download_link(responses_data, "Download Responses.csv")
|
241 |
+
download_edited_responses_link_csv = create_download_link(edited_responses_data, "Download Edited Responses.csv")
|
242 |
+
|
243 |
+
# Create download links for TXT files
|
244 |
+
download_responses_link_txt = create_download_link_txt(responses_data, "Download Responses.txt")
|
245 |
+
download_edited_responses_link_txt = create_download_link_txt(edited_responses_data, "Download Edited Responses.txt")
|
246 |
+
|
247 |
+
# Display download links for CSV files
|
248 |
+
st.markdown(download_responses_link_csv, unsafe_allow_html=True)
|
249 |
+
st.markdown(download_edited_responses_link_csv, unsafe_allow_html=True)
|
250 |
|
251 |
+
# Display download links for TXT files
|
252 |
+
st.markdown(download_responses_link_txt, unsafe_allow_html=True)
|
253 |
+
st.markdown(download_edited_responses_link_txt, unsafe_allow_html=True)
|