| import pandas as pd
|
| import gradio as gr
|
|
|
| def analyze_csv(file_obj):
|
|
|
| df = pd.read_csv(file_obj.name)
|
|
|
|
|
| row_count = len(df)
|
| col_count = len(df.columns)
|
|
|
|
|
| summary_stats = df.describe().round(2)
|
|
|
|
|
| head_df = df.head()
|
|
|
|
|
| report = f"### π Data Overview\n* **Total Rows:** {row_count}\n* **Total Columns:** {col_count}\n\n"
|
| report += "The tool has automatically processed the mathematical summary and extracted a data preview below."
|
|
|
| return report, summary_stats, head_df
|
|
|
|
|
| with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| gr.Markdown("# π Automated Business Data Analyzer")
|
| gr.Markdown("Upload any raw CSV file to instantly generate a statistical breakdown.")
|
|
|
| with gr.Row():
|
| file_input = gr.File(label="Upload CSV File here", file_types=[".csv"])
|
|
|
| with gr.Row():
|
| text_output = gr.Markdown()
|
|
|
| with gr.Row():
|
| stats_output = gr.Dataframe(label="Mathematical Summary (Averages, Min, Max)")
|
|
|
| with gr.Row():
|
| head_output = gr.Dataframe(label="Raw Data Preview (First 5 Rows)")
|
|
|
|
|
| file_input.upload(fn=analyze_csv, inputs=file_input, outputs=[text_output, stats_output, head_output])
|
|
|
| if __name__ == "__main__":
|
| demo.launch() |