import streamlit as st
import pandas as pd
st.set_page_config(page_title="Student CSV Progress Report", layout="wide")
st.title("π Dynamic Student Progress Report")
st.write("Generate a structured academic report card by entering details and uploading a marks CSV file.")
# Layout: Split page into Input Form (left) and Generated Report (right)
col_input, col_report = st.columns([1, 2])
# Left column: Inputs
with col_input:
st.subheader("π Input Information")
with st.form("report_form"):
student_name = st.text_input("Student Name", value="Jane Doe")
roll_number = st.text_input("Roll Number", value="CSE-2026-104")
branch = st.selectbox("Branch", ["Computer Science", "Electronics", "Mechanical", "Civil"])
uploaded_file = st.file_uploader("Upload Marks CSV File", type=["csv"])
generate = st.form_submit_button("Generate Report Card")
# Right column: Output Report Card
with col_report:
st.subheader("π Generated Report Card")
if generate:
if not student_name.strip() or not roll_number.strip():
st.error("Please enter a valid Student Name and Roll Number.")
elif uploaded_file is None:
st.warning("Please upload a CSV file containing the marks.")
else:
try:
# Load and parse CSV
df = pd.read_csv(uploaded_file)
# Check for required columns
required_cols = {"Subject", "Marks", "Grade"}
if not required_cols.issubset(df.columns):
st.error("The CSV file must contain 'Subject', 'Marks', and 'Grade' columns.")
else:
# 1. Student Details Section
with st.container(border=True):
st.subheader("π€ Student Profile Details")
c1, c2, c3 = st.columns(3)
c1.markdown(f"**Name:** {student_name}")
c2.markdown(f"**Roll Number:** {roll_number}")
c3.markdown(f"**Branch:** {branch}")
st.divider()
# 2. Subject Marks Table
with st.container(border=True):
st.subheader("π Academic Grades Breakdown")
st.dataframe(df, use_container_width=True, hide_index=True)
st.divider()
# 3. Summary Analytics
with st.container(border=True):
st.subheader("π Performance Summary")
avg_score = df["Marks"].mean()
max_score = df["Marks"].max()
total_subjects = len(df)
sm1, sm2, sm3 = st.columns(3)
sm1.metric("Total Subjects", total_subjects)
sm2.metric("Average Score", f"{avg_score:.2f}%")
sm3.metric("Highest Mark", f"{max_score}%")
# Remarks
st.write("**Overall Remarks:**")
if avg_score >= 90:
st.success("Outstanding! The student shows exceptional performance across all subjects.")
elif avg_score >= 75:
st.info("Good! Consistent performance, with room for improvement in specific areas.")
else:
st.warning("Needs Attention. Recommend regular extra sessions and tutorial support.")
except Exception as e:
st.error(f"Error reading CSV file: {e}")
else:
st.info("Fill out the form and click 'Generate Report Card' to view the report.")