Spaces:
Sleeping
Sleeping
DrishtiSharma
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -85,6 +85,36 @@ if st.session_state.df is not None and st.session_state.show_preview:
|
|
85 |
st.subheader("π Dataset Preview")
|
86 |
st.dataframe(st.session_state.df.head())
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
# SQL-RAG Analysis
|
89 |
if st.session_state.df is not None:
|
90 |
temp_dir = tempfile.TemporaryDirectory()
|
|
|
85 |
st.subheader("π Dataset Preview")
|
86 |
st.dataframe(st.session_state.df.head())
|
87 |
|
88 |
+
# Function to create TXT file
|
89 |
+
def generate_txt(content):
|
90 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".txt") as tmp_file:
|
91 |
+
tmp_file.write(content.encode('utf-8'))
|
92 |
+
return tmp_file.name
|
93 |
+
|
94 |
+
# Function to create PDF with report text and visualizations
|
95 |
+
def generate_pdf(report_text, figures):
|
96 |
+
pdf = FPDF()
|
97 |
+
pdf.add_page()
|
98 |
+
pdf.set_font("Arial", size=12)
|
99 |
+
|
100 |
+
# Add report text
|
101 |
+
for line in report_text.split('\n'):
|
102 |
+
pdf.multi_cell(0, 10, line)
|
103 |
+
|
104 |
+
# Add visualizations
|
105 |
+
for fig in figures:
|
106 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as img_file:
|
107 |
+
fig.write_image(img_file.name)
|
108 |
+
pdf.add_page()
|
109 |
+
pdf.image(img_file.name, x=10, y=10, w=190)
|
110 |
+
|
111 |
+
# Save PDF
|
112 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp_pdf:
|
113 |
+
pdf.output(tmp_pdf.name)
|
114 |
+
return tmp_pdf.name
|
115 |
+
|
116 |
+
|
117 |
+
|
118 |
# SQL-RAG Analysis
|
119 |
if st.session_state.df is not None:
|
120 |
temp_dir = tempfile.TemporaryDirectory()
|