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()