jcmachicao commited on
Commit
89500a9
1 Parent(s): f2a4ed0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -18
app.py CHANGED
@@ -5,22 +5,26 @@ import pandas as pd
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)
 
 
 
 
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)