File size: 1,083 Bytes
d1ac33a
 
 
 
 
bf2a9d9
d1ac33a
bf2a9d9
d1ac33a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bf2a9d9
d1ac33a
 
 
 
 
 
 
 
 
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
import pandas as pd
import gradio as gr
import ydata_profiling
import os

def generate_eda_report(file_path):
    try:
        df = pd.read_csv(file_path)
    except Exception as e:
        return f"Error reading CSV file: {e}"

    if len(df) / 1024 / 1024 > 100:
        return "Error: Dataset size exceeds 100MB."

    profile = ydata_profiling.ProfileReport(df, title="EDA Report")
    report_path = "eda_report.html"
    profile.to_file(report_path)

    # Read the HTML content as a string
    with open(report_path, "r", encoding="utf-8") as f:
        html_report = f.read()

    # Clean up the generated file
    os.remove(report_path)

    return html_report

iface = gr.Interface(
    fn=generate_eda_report,
    inputs=gr.File(type="filepath", label="Upload your CSV dataset (max 100MB)"),
    outputs=gr.HTML(label="EDA Report"),
    title="Effortless Dataset Insights",
    description="Upload your CSV file and get an instant Exploratory Data Analysis report in HTML format.",
)

app = gr.mount_gradio_app(iface, path="/")

if __name__ == "__main__":
    app.launch()