import pandas as pd from ydata_profiling import ProfileReport import gradio as gr def generate_report(file): try: # Read the uploaded CSV file df = pd.read_csv(file.name) # Generate the profiling report report = ProfileReport(df, title="Data Report", explorative=True) # Render the report as an HTML string report_html = report.to_html() return report_html except Exception as e: return f"An error occurred: {str(e)}" # Define the footer HTML content footer = """
""" # Create a Gradio interface with custom layout with gr.Blocks() as app: gr.Markdown("# Data Report Generator") # File input section with gr.Row(): with gr.Column(scale=1): upload = gr.File(label="Upload your CSV file") with gr.Column(scale=1): generate_btn = gr.Button("Generate Report") # Output section for displaying the report report_output = gr.HTML() # Action to generate and display the report generate_btn.click(fn=generate_report, inputs=upload, outputs=report_output) # Add the footer to the app gr.HTML(footer) # Launch the Gradio app app.launch()