Spaces:
Runtime error
Runtime error
jcmachicao
commited on
Commit
•
89500a9
1
Parent(s):
f2a4ed0
Update app.py
Browse files
app.py
CHANGED
@@ -5,22 +5,26 @@ import pandas as pd
|
|
5 |
file = st.file_uploader('Seleccione un archivo: ')
|
6 |
df = file
|
7 |
|
8 |
-
|
9 |
-
|
|
|
10 |
|
11 |
-
#
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
text
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
5 |
file = st.file_uploader('Seleccione un archivo: ')
|
6 |
df = file
|
7 |
|
8 |
+
if file is None:
|
9 |
+
pass
|
10 |
+
else:
|
11 |
|
12 |
+
# Sidebar option
|
13 |
+
option = st.sidebar.selectbox('Classify results by:', ('Pregunta', 'Categoría'))
|
14 |
+
|
15 |
+
# Group dataframe by chosen option
|
16 |
+
if option == 'Pregunta':
|
17 |
+
grouped_df = df.groupby('Pregunta')
|
18 |
+
elif option == 'Categoría':
|
19 |
+
grouped_df = df.groupby('Categoría')
|
20 |
+
|
21 |
+
# Generate text with bullets
|
22 |
+
text = ''
|
23 |
+
for name, group in grouped_df:
|
24 |
+
text += f'{name}:\n\n'
|
25 |
+
for index, row in group.iterrows():
|
26 |
+
text += f'- {row["Item"]}\n'
|
27 |
+
text += '\n'
|
28 |
+
|
29 |
+
# Download link for text file
|
30 |
+
st.markdown(f'<a href="data:text/plain;charset=utf-8,{text}" download="result.txt">Download Text File</a>', unsafe_allow_html=True)
|