Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,39 +10,43 @@ class DataAnalyzer:
|
|
10 |
self.temp_dir = tempfile.mkdtemp()
|
11 |
|
12 |
def generate_sweetviz_report(self, df):
|
13 |
-
# Generate report
|
14 |
report = sv.analyze(df)
|
15 |
report_path = os.path.join(self.temp_dir, "report.html")
|
16 |
report.show_html(report_path, open_browser=False)
|
17 |
|
18 |
-
# Read and modify the HTML content
|
19 |
with open(report_path, 'r', encoding='utf-8') as f:
|
20 |
html_content = f.read()
|
21 |
-
|
22 |
-
# Remove logo
|
|
|
|
|
23 |
html_content = re.sub(r'<div class="nav-logo">.*?</div>', '', html_content, flags=re.DOTALL)
|
24 |
|
25 |
-
#
|
26 |
custom_css = """
|
27 |
<style>
|
28 |
-
.nav-logo {
|
29 |
display: none !important;
|
30 |
}
|
31 |
.container {
|
32 |
width: 100% !important;
|
33 |
max-width: none !important;
|
34 |
padding: 0 !important;
|
35 |
-
|
36 |
-
.dataframe {
|
37 |
-
width: 100% !important;
|
38 |
}
|
39 |
.nav {
|
40 |
-
padding: 0 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
}
|
42 |
</style>
|
43 |
"""
|
44 |
|
45 |
-
# Insert custom CSS
|
46 |
html_content = html_content.replace('</head>', f'{custom_css}</head>')
|
47 |
|
48 |
# Clean up
|
@@ -69,7 +73,7 @@ def create_interface():
|
|
69 |
|
70 |
# Wrap report in container with fixed height
|
71 |
report_with_style = f"""
|
72 |
-
<div style="height: 800px; overflow: auto; padding:
|
73 |
{report}
|
74 |
</div>
|
75 |
"""
|
|
|
10 |
self.temp_dir = tempfile.mkdtemp()
|
11 |
|
12 |
def generate_sweetviz_report(self, df):
|
|
|
13 |
report = sv.analyze(df)
|
14 |
report_path = os.path.join(self.temp_dir, "report.html")
|
15 |
report.show_html(report_path, open_browser=False)
|
16 |
|
|
|
17 |
with open(report_path, 'r', encoding='utf-8') as f:
|
18 |
html_content = f.read()
|
19 |
+
|
20 |
+
# Remove Sweetviz logo and header
|
21 |
+
html_content = re.sub(r'<div class="header">.*?</div>', '', html_content, flags=re.DOTALL)
|
22 |
+
html_content = re.sub(r'<div class="logo">.*?</div>', '', html_content, flags=re.DOTALL)
|
23 |
html_content = re.sub(r'<div class="nav-logo">.*?</div>', '', html_content, flags=re.DOTALL)
|
24 |
|
25 |
+
# Additional CSS to hide unwanted elements and improve layout
|
26 |
custom_css = """
|
27 |
<style>
|
28 |
+
.header, .logo, .nav-logo {
|
29 |
display: none !important;
|
30 |
}
|
31 |
.container {
|
32 |
width: 100% !important;
|
33 |
max-width: none !important;
|
34 |
padding: 0 !important;
|
35 |
+
margin-top: 0 !important;
|
|
|
|
|
36 |
}
|
37 |
.nav {
|
38 |
+
padding-top: 0 !important;
|
39 |
+
}
|
40 |
+
.content {
|
41 |
+
padding-top: 0 !important;
|
42 |
+
}
|
43 |
+
.tab-content {
|
44 |
+
margin-top: 0 !important;
|
45 |
}
|
46 |
</style>
|
47 |
"""
|
48 |
|
49 |
+
# Insert custom CSS before closing head tag
|
50 |
html_content = html_content.replace('</head>', f'{custom_css}</head>')
|
51 |
|
52 |
# Clean up
|
|
|
73 |
|
74 |
# Wrap report in container with fixed height
|
75 |
report_with_style = f"""
|
76 |
+
<div style="height: 800px; overflow: auto; padding: 0;">
|
77 |
{report}
|
78 |
</div>
|
79 |
"""
|