I have an excel file which has 2 columns. I want to display this excel to our users and allow them to validate each line in excel by having 2 checkboxes next to each line. How can i do it via Streamlit?
The exact UI can be done in a number of different ways, but here’s one way:
import streamlit as st
import pandas as pd
df = pd.read_excel("sheet.xlsx")[:10]
cols = st.columns(4)
cols[0].write(f"## {df.columns[0]}")
cols[2].write(f"## {df.columns[1]}")
for idx, row in enumerate(df.itertuples()):
cols = st.columns(4)
cols[0].write(row[0])
cols[1].checkbox(f"{df.columns[0]} valid?", key=f"col1_valid_{idx}")
cols[2].write(row[1])
cols[3].checkbox(f"{df.columns[1]} valid?", key=f"col2_valid_{idx}")
st.divider()
st.header("Results:")
for idx, row in enumerate(df.itertuples()):
cols = st.columns(2)
with cols[0]:
value = row[0]
valid = st.session_state.get(f"col1_valid_{idx}", False)
valid_emoji = "✅" if valid else "❌"
cols[0].write(f"{value} {valid_emoji}")
with cols[1]:
value = row[1]
valid = st.session_state.get(f"col2_valid_{idx}", False)
valid_emoji = "✅" if valid else "❌"
cols[1].write(f"{value} {valid_emoji}")
my csv file looks like this.

Now i was trying to put checkboxes in the columns D (good), column E (bad), Column F(OK). (user can check all three)
After the user check boxes i want to capture it as another dataframe and save it in a new csv.


