Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -86,10 +86,30 @@ if st.session_state.df is not None and st.session_state.show_preview:
|
|
| 86 |
st.dataframe(st.session_state.df.head())
|
| 87 |
|
| 88 |
# Function to create TXT file
|
| 89 |
-
def
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
# Function to create PDF with report text and visualizations
|
| 95 |
def create_pdf_report_with_viz(report, conclusion, visualizations):
|
|
|
|
| 86 |
st.dataframe(st.session_state.df.head())
|
| 87 |
|
| 88 |
# Function to create TXT file
|
| 89 |
+
def create_text_report_with_viz_temp(report, conclusion, visualizations):
|
| 90 |
+
content = f"### Analysis Report\n\n{report}\n\n### Visualizations\n"
|
| 91 |
+
|
| 92 |
+
for i, fig in enumerate(visualizations, start=1):
|
| 93 |
+
fig_title = fig.layout.title.text if fig.layout.title.text else f"Visualization {i}"
|
| 94 |
+
x_axis = fig.layout.xaxis.title.text if fig.layout.xaxis.title.text else "X-axis"
|
| 95 |
+
y_axis = fig.layout.yaxis.title.text if fig.layout.yaxis.title.text else "Y-axis"
|
| 96 |
+
|
| 97 |
+
content += f"\n{i}. {fig_title}\n"
|
| 98 |
+
content += f" - X-axis: {x_axis}\n"
|
| 99 |
+
content += f" - Y-axis: {y_axis}\n"
|
| 100 |
+
|
| 101 |
+
if fig.data:
|
| 102 |
+
trace_types = set(trace.type for trace in fig.data)
|
| 103 |
+
content += f" - Chart Type(s): {', '.join(trace_types)}\n"
|
| 104 |
+
else:
|
| 105 |
+
content += " - No data available in this visualization.\n"
|
| 106 |
+
|
| 107 |
+
content += f"\n\n### Conclusion\n\n{conclusion}"
|
| 108 |
+
|
| 109 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".txt", mode='w', encoding='utf-8') as temp_txt:
|
| 110 |
+
temp_txt.write(content)
|
| 111 |
+
return temp_txt.name
|
| 112 |
+
|
| 113 |
|
| 114 |
# Function to create PDF with report text and visualizations
|
| 115 |
def create_pdf_report_with_viz(report, conclusion, visualizations):
|