Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -78,6 +78,21 @@ elif input_option == "Upload CSV File":
|
|
78 |
except Exception as e:
|
79 |
st.error(f"Error loading file: {e}")
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
# Show Dataset Preview Only After Loading
|
82 |
if st.session_state.df is not None and st.session_state.show_preview:
|
83 |
st.subheader("π Dataset Preview")
|
|
|
78 |
except Exception as e:
|
79 |
st.error(f"Error loading file: {e}")
|
80 |
|
81 |
+
def save_as_txt(content, filename):
|
82 |
+
with open(filename, "w") as f:
|
83 |
+
f.write(content)
|
84 |
+
return filename
|
85 |
+
|
86 |
+
def save_as_pdf(content, filename):
|
87 |
+
from fpdf import FPDF
|
88 |
+
pdf = FPDF()
|
89 |
+
pdf.add_page()
|
90 |
+
pdf.set_font("Arial", size=12)
|
91 |
+
for line in content.split('\n'):
|
92 |
+
pdf.multi_cell(0, 10, line)
|
93 |
+
pdf.output(filename)
|
94 |
+
return filename
|
95 |
+
|
96 |
# Show Dataset Preview Only After Loading
|
97 |
if st.session_state.df is not None and st.session_state.show_preview:
|
98 |
st.subheader("π Dataset Preview")
|