display a table, and create each row of this table by user manually type-in。 There is a button, called "create new entry"
To upload files, please first save the app
import streamlit as st
import pandas as pd
# Initialize the data in session state if it doesn't exist
if 'data' not in st.session_state:
st.session_state.data = pd.DataFrame(columns=['Name', 'Age', 'City'])
st.title('Manual Data Entry Table')
# Create form for data input
with st.form(key='entry_form'):
name = st.text_input('Name')
age = st.number_input('Age', min_value=0, max_value=120)
city = st.text_input('City')
submit_button = st.form_submit_button(label='Create New Entry')
if submit_button:
# Create new row
new_row = pd.DataFrame({
'Name': [name],
'Age': [age],
'City': [city]
})
# Append the new row to existing data
st.session_state.data = pd.concat([st.session_state.data, new_row], ignore_index=True)
# Display the table
if not st.session_state.data.empty:
st.subheader('Current Data')
st.table(st.session_state.data)
else:
st.info('No data entered yet. Use the form above to add entries.')
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?