Spaces:
Sleeping
Sleeping
| 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 = """ | |
| <div style="text-align: center; margin-top: 20px;"> | |
| <a href="https://www.linkedin.com/in/pejman-ebrahimi-4a60151a7/" target="_blank">LinkedIn</a> | | |
| <a href="https://github.com/arad1367" target="_blank">GitHub</a> | | |
| <a href="https://arad1367.pythonanywhere.com/" target="_blank">Live demo of my PhD defense</a> | |
| <br> | |
| Made with π by Pejman Ebrahimi | |
| </div> | |
| """ | |
| # 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() | |