the code runs quite when using streamlit (server), however when trying it using stlite it keeps saying error in saving
is it possible to save to the excel while its within the exe file? like im using the excel such as database
st.title("Driving Teacher's Dashboard")
# Load the existing Excel file into a DataFrame
try:
students_df = pd.read_excel('files_omar/students.xlsx')
st.dataframe(students_df.sort_index(ascending=False))
# Add a form to input new data
st.subheader("Add New Student")
with st.form(key='add_student_form'):
name = st.text_input("Name")
age = st.number_input("Age", min_value=0, max_value=150)
grade = st.selectbox("Grade", ['A', 'B', 'C', 'D', 'F'])
submit_button = st.form_submit_button("Add Student")
if submit_button:
# Create a new DataFrame with the input data
new_student = pd.DataFrame({
'Name': [name],
'Age': [age],
'Grade': [grade]
})
# Append the new student data to the existing DataFrame
students_df = students_df.append(new_student, ignore_index=True)
# Write the updated DataFrame back to the Excel file
students_df.to_excel('files_omar/students.xlsx', index=False)
st.success("New student added successfully!")
except FileNotFoundError:
st.error("File not found: 'files_omar/students.xlsx'")
except Exception as e:
st.error(f"An error occurred: {str(e)}")