jcmachicao's picture
Update app.py
dca7be1
raw
history blame
1.09 kB
import streamlit as st
import pandas as pd
# Load dataframe
file = st.file_uploader('Seleccione un archivo CSV: ')
df = pd.read_csv(file)
if uploaded_file is not None:
# Load the Excel file into a Pandas dataframe
df = pd.read_excel(uploaded_file, engine='openpyxl', type="xlsx")
# Show the dataframe in Streamlit
st.write(df.head())
st.write(df.columns)
# Sidebar option
option = st.sidebar.selectbox('Clasificar resultados por:', ('Pregunta', 'Categoria'))
# Group dataframe by chosen option
if option == 'Pregunta':
grouped_df = df.groupby('Pregunta')
elif option == 'Categoria':
grouped_df = df.groupby('Categoria')
# Generate text with bullets
text = ''
for name, group in grouped_df:
text += f'{name}:\n\n'
for index, row in group.iterrows():
text += f'- {row["Item"]}\n'
text += '\n'
# Download link for text file
st.markdown(f'<a href="data:text/plain;charset=utf-8,{text}" download="result.txt">Download Text File</a>', unsafe_allow_html=True)