Spaces:
Runtime error
Runtime error
Upload Engg_Result_analysis.py
Browse files- Engg_Result_analysis.py +45 -0
Engg_Result_analysis.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
# Function to analyze the status column
|
| 5 |
+
def analyze_status(df):
|
| 6 |
+
if 'Status' not in df.columns:
|
| 7 |
+
st.error("The uploaded file does not contain a 'status' column.")
|
| 8 |
+
return None
|
| 9 |
+
|
| 10 |
+
status_counts = df['Status'].value_counts()
|
| 11 |
+
return status_counts
|
| 12 |
+
|
| 13 |
+
# Streamlit app
|
| 14 |
+
def main():
|
| 15 |
+
st.title("Engg Students Result Analysis")
|
| 16 |
+
st.write("Upload a CSV or Excel file to analyze student status.")
|
| 17 |
+
|
| 18 |
+
uploaded_file = st.file_uploader("Choose a CSV or Excel file", type=["csv", "xlsx"])
|
| 19 |
+
|
| 20 |
+
if uploaded_file is not None:
|
| 21 |
+
try:
|
| 22 |
+
# Determine the file type and read accordingly
|
| 23 |
+
if uploaded_file.name.endswith('.csv'):
|
| 24 |
+
df = pd.read_csv(uploaded_file)
|
| 25 |
+
elif uploaded_file.name.endswith('.xlsx'):
|
| 26 |
+
df = pd.read_excel(uploaded_file)
|
| 27 |
+
else:
|
| 28 |
+
st.error("Unsupported file format.")
|
| 29 |
+
return
|
| 30 |
+
|
| 31 |
+
st.write("File uploaded successfully!")
|
| 32 |
+
st.write("Here's a preview of the data:")
|
| 33 |
+
st.dataframe(df.head())
|
| 34 |
+
|
| 35 |
+
status_counts = analyze_status(df)
|
| 36 |
+
if status_counts is not None:
|
| 37 |
+
st.write("### Analysis of Student Status")
|
| 38 |
+
st.write(status_counts)
|
| 39 |
+
st.bar_chart(status_counts)
|
| 40 |
+
|
| 41 |
+
except Exception as e:
|
| 42 |
+
st.error(f"An error occurred: {e}")
|
| 43 |
+
|
| 44 |
+
if __name__ == "__main__":
|
| 45 |
+
main()
|