File size: 1,598 Bytes
56346ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
da993cd
56346ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
41
42
43
44
45
46
47
48
49
50
51
52
53
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()