Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import pandas as pd | |
| # Function to analyze the status column | |
| def analyze_status(df): | |
| if 'Status' not in df.columns: | |
| st.error("The uploaded file does not contain a 'status' column.") | |
| return None | |
| status_counts = df['Status'].value_counts() | |
| return status_counts | |
| # Streamlit app | |
| def main(): | |
| st.title("Engg Students Result Analysis") | |
| st.write("Upload a CSV or Excel file to analyze student status.") | |
| uploaded_file = st.file_uploader("Choose a CSV or Excel file", type=["csv", "xlsx"]) | |
| if uploaded_file is not None: | |
| try: | |
| # Determine the file type and read accordingly | |
| if uploaded_file.name.endswith('.csv'): | |
| df = pd.read_csv(uploaded_file) | |
| elif uploaded_file.name.endswith('.xlsx'): | |
| df = pd.read_excel(uploaded_file) | |
| else: | |
| st.error("Unsupported file format.") | |
| return | |
| st.write("File uploaded successfully!") | |
| st.write("Here's a preview of the data:") | |
| st.dataframe(df.head()) | |
| status_counts = analyze_status(df) | |
| if status_counts is not None: | |
| st.write("### Analysis of Student Status") | |
| st.write(status_counts) | |
| st.bar_chart(status_counts) | |
| except Exception as e: | |
| st.error(f"An error occurred: {e}") | |
| if __name__ == "__main__": | |
| main() | |