Download app.py from Srinias/Demo: direct link, hf CLI and curl.
- Browser
- Download file 933 Bytes
-
https://huggingface.co/spaces/Srinias/Demo/resolve/main/app.py
- Command line
-
hf download hf://spaces/Srinias/Demo/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Srinias/Demo/resolve/main/app.py
933 Bytes
| import gradio as gr | |
| import pandas as pd | |
| def process_marksheet(file): | |
| df = pd.read_csv(file.name) | |
| # Calculate Total | |
| subjects = ["Mathematics", "Science", "English", "Social_Studies", "Computer_Science"] | |
| df["Total"] = df[subjects].sum(axis=1) | |
| # Calculate Percentage | |
| df["Percentage"] = (df["Total"] / 500) * 100 | |
| output_file = "updated_marksheet.csv" | |
| df.to_csv(output_file, index=False) | |
| return df, output_file | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# 📊 Student Marksheet Processor") | |
| gr.Markdown("Upload a CSV file to calculate Total and Percentage.") | |
| file_input = gr.File(file_types=[".csv"]) | |
| process_btn = gr.Button("Process Marksheet") | |
| output_table = gr.Dataframe() | |
| download_file = gr.File(label="Download Updated CSV") | |
| process_btn.click( | |
| process_marksheet, | |
| inputs=file_input, | |
| outputs=[output_table, download_file] | |
| ) | |
| demo.launch() |