Spaces:
Runtime error
Runtime error
import streamlit as st | |
import pandas as pd | |
# Load dataframe | |
file = st.file_uploader('Seleccione un archivo: ') | |
df = file | |
# Sidebar option | |
option = st.sidebar.selectbox('Classify results by:', ('Question', 'Category')) | |
# Group dataframe by chosen option | |
if option == 'Question': | |
grouped_df = df.groupby('Question') | |
elif option == 'Category': | |
grouped_df = df.groupby('Category') | |
# 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) | |