Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import gradio as gr
|
3 |
+
import ydata_profiling
|
4 |
+
import os
|
5 |
+
|
6 |
+
def generate_eda_report(data):
|
7 |
+
try:
|
8 |
+
df = pd.read_csv(data.name)
|
9 |
+
except Exception as e:
|
10 |
+
return f"Error reading CSV file: {e}"
|
11 |
+
|
12 |
+
if len(df) / 1024 / 1024 > 100:
|
13 |
+
return "Error: Dataset size exceeds 100MB."
|
14 |
+
|
15 |
+
profile = ydata_profiling.ProfileReport(df, title="EDA Report")
|
16 |
+
report_path = "eda_report.html"
|
17 |
+
profile.to_file(report_path)
|
18 |
+
|
19 |
+
# Read the HTML content as a string
|
20 |
+
with open(report_path, "r", encoding="utf-8") as f:
|
21 |
+
html_report = f.read()
|
22 |
+
|
23 |
+
# Clean up the generated file
|
24 |
+
os.remove(report_path)
|
25 |
+
|
26 |
+
return html_report
|
27 |
+
|
28 |
+
iface = gr.Interface(
|
29 |
+
fn=generate_eda_report,
|
30 |
+
inputs=gr.File(type="file", label="Upload your CSV dataset (max 100MB)"),
|
31 |
+
outputs=gr.HTML(label="EDA Report"),
|
32 |
+
title="Effortless Dataset Insights",
|
33 |
+
description="Upload your CSV file and get an instant Exploratory Data Analysis report in HTML format.",
|
34 |
+
)
|
35 |
+
|
36 |
+
app = gr.mount_gradio_app(iface, path="/")
|
37 |
+
|
38 |
+
if __name__ == "__main__":
|
39 |
+
app.launch()
|