File size: 1,942 Bytes
0a5d39a 7a75289 0a5d39a 71c9026 dd375ae 1065d81 e7f020c b9cae72 a899a25 d4abba2 b9cae72 e7f020c d4abba2 0a5d39a d4abba2 723b0f1 d4abba2 a899a25 a141a8d d4abba2 a141a8d d4abba2 492d55e d4abba2 492d55e d4abba2 492d55e d4abba2 b507dc9 b9cae72 |
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
import ydata_profiling
import gradio as gr
from pydantic_settings import BaseSettings
from tempfile import NamedTemporaryFile
import sweetviz as sv
# from dataprep.datasets import load_dataset
# from dataprep.eda import create_report
def generate_report(file, type):
df = pd.read_csv(file) if file.name.endswith(".csv") else pd.read_excel(file)
pandas_html_report =ydata_profiling.ProfileReport(df).to_html()
temp_file1 = NamedTemporaryFile(delete=False, suffix=".html")
temp_file1.write(pandas_html_report.encode('utf-8'))
temp_file1.close()
# dataprep_report = create_report(df)
# temp_file2 = NamedTemporaryFile(delete=False, suffix=".html")
# temp_file2.write(dataprep_report.encode('utf-8'))
# temp_file2.close()
sweetviz_report = sv.analyze(df)
sweetviz_report=sweetviz_report.to_html()
temp_file3 = NamedTemporaryFile(delete=False, suffix=".html")
temp_file3.write(sweetviz_report.encode('utf-8'))
temp_file3.close()
return temp_file1.name ,temp_file2.name ,temp_file3.nam
with gr.Blocks() as cluster:
with gr.Column():
with gr.Row():
file=gr.File(file_types=['.csv', '.xlsx'], label="Upload a CSV or Excel file")
btn=gr.Button(value="Download Report")
with gr.Row():
gr.HTML(value="""<h1 style="color: #3399FF; text-shadow: 1px 1px 2px #ddd;">PANDAS REPORT</h1>""")
out1=gr.File(label="Download CSV")
gr.HTML(value="""<h1 style="color: #3399FF; text-shadow: 1px 1px 2px #ddd;">DATAPREP REPORT</h1>""")
out2=gr.File(label="Download CSV")
gr.HTML(value="""<h1 style="color: #3399FF; text-shadow: 1px 1px 2px #ddd;">SWEETVIZ REPORT</h1>""")
out3=gr.File(label="Download CSV")
btn.click(generate_report,inputs=[file],outputs=[out1,out3])
cluster.launch()
|