Update app.py
Browse files
app.py
CHANGED
@@ -2,14 +2,11 @@ import streamlit as st
|
|
2 |
import pandas as pd
|
3 |
from ydata_profiling import ProfileReport
|
4 |
|
5 |
-
# Set page config (must be the first Streamlit command)
|
6 |
st.set_page_config(page_title="Dynamic Data Profiling", layout="wide", page_icon="📊")
|
7 |
|
8 |
-
# App title
|
9 |
st.title("Dynamic Data Profiling with ydata-profiling")
|
10 |
st.write("Upload your CSV file and get a complete interactive profiling report!")
|
11 |
|
12 |
-
# File uploader widget
|
13 |
uploaded_file = st.file_uploader("Upload a CSV file", type="csv")
|
14 |
|
15 |
if uploaded_file is not None:
|
@@ -21,11 +18,23 @@ if uploaded_file is not None:
|
|
21 |
# Generate the profile report
|
22 |
with st.spinner("Generating profile report..."):
|
23 |
profile = ProfileReport(df, title="Profiling Report", explorative=True)
|
24 |
-
#
|
25 |
report_html = profile.to_html()
|
26 |
-
|
27 |
-
#
|
28 |
st.components.v1.html(report_html, height=1200, scrolling=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
except Exception as e:
|
30 |
st.error(f"An error occurred: {e}")
|
31 |
else:
|
|
|
2 |
import pandas as pd
|
3 |
from ydata_profiling import ProfileReport
|
4 |
|
|
|
5 |
st.set_page_config(page_title="Dynamic Data Profiling", layout="wide", page_icon="📊")
|
6 |
|
|
|
7 |
st.title("Dynamic Data Profiling with ydata-profiling")
|
8 |
st.write("Upload your CSV file and get a complete interactive profiling report!")
|
9 |
|
|
|
10 |
uploaded_file = st.file_uploader("Upload a CSV file", type="csv")
|
11 |
|
12 |
if uploaded_file is not None:
|
|
|
18 |
# Generate the profile report
|
19 |
with st.spinner("Generating profile report..."):
|
20 |
profile = ProfileReport(df, title="Profiling Report", explorative=True)
|
21 |
+
# Convert report to HTML
|
22 |
report_html = profile.to_html()
|
23 |
+
|
24 |
+
# Show the report in an iframe
|
25 |
st.components.v1.html(report_html, height=1200, scrolling=True)
|
26 |
+
|
27 |
+
# Provide a download button for the HTML
|
28 |
+
st.write("### Download the Profiling Report")
|
29 |
+
# Convert HTML string to bytes
|
30 |
+
report_bytes = report_html.encode('utf-8')
|
31 |
+
st.download_button(
|
32 |
+
label="Download HTML",
|
33 |
+
data=report_bytes,
|
34 |
+
file_name="profiling_report.html",
|
35 |
+
mime="text/html"
|
36 |
+
)
|
37 |
+
|
38 |
except Exception as e:
|
39 |
st.error(f"An error occurred: {e}")
|
40 |
else:
|