Spaces:
Runtime error
Runtime error
File size: 1,492 Bytes
29b8496 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
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()
|