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