Roaster_Uenr / app.py
mistermprah's picture
Update app.py
975946e verified
raw
history blame
1.25 kB
import streamlit as st
import pandas as pd
# Function to parse the uploaded roster file
def parse_roster(file):
df = pd.read_excel(file, engine='openpyxl')
st.write("File read successfully. Columns in the file:", df.columns)
return df
# Function to generate the yearly roster
def generate_yearly_roster(df):
nurses = df['NAMES'].unique()
roles = df['RANK'].unique()
# Your logic to generate the yearly roster goes here
yearly_roster = df.copy() # Placeholder for demonstration
return yearly_roster
# Streamlit app setup
st.title("Nurse Duty Roster Generator")
uploaded_file = st.file_uploader("Upload the current roster file", type=["xlsx"])
if uploaded_file is not None:
try:
current_roster = parse_roster(uploaded_file)
one_year_roster = generate_yearly_roster(current_roster)
st.write("Generated Yearly Roster:")
st.dataframe(one_year_roster)
# Allow download of the generated roster
st.download_button(
label="Download Yearly Roster",
data=one_year_roster.to_excel(index=False),
file_name="yearly_roster.xlsx"
)
except Exception as e:
st.error(f"An error occurred: {e}")