Spaces:
Runtime error
Runtime error
Commit
Β·
1a8d3b2
1
Parent(s):
0310afc
Update app.py
Browse files
app.py
CHANGED
@@ -91,7 +91,6 @@ def reset_textbox():
|
|
91 |
|
92 |
# Episodic and Semantic IO
|
93 |
def list_files(file_path):
|
94 |
-
import os
|
95 |
icon_csv = "π "
|
96 |
icon_txt = "π "
|
97 |
current_directory = os.getcwd()
|
@@ -99,6 +98,9 @@ def list_files(file_path):
|
|
99 |
for filename in os.listdir(current_directory):
|
100 |
if filename.endswith(".csv"):
|
101 |
file_list.append(icon_csv + filename)
|
|
|
|
|
|
|
102 |
elif filename.endswith(".txt"):
|
103 |
file_list.append(icon_txt + filename)
|
104 |
if file_list:
|
@@ -143,21 +145,6 @@ def append_file(file_path, content):
|
|
143 |
except:
|
144 |
return "Error occurred while appending to file."
|
145 |
|
146 |
-
# Allow the user to upload a CSV file
|
147 |
-
uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
|
148 |
-
|
149 |
-
# If a file was uploaded, display its contents as a pandas DataFrame
|
150 |
-
if uploaded_file is not None:
|
151 |
-
data = pd.read_csv(uploaded_file)
|
152 |
-
st.write(data)
|
153 |
-
|
154 |
-
# Add a link to download the CSV file
|
155 |
-
st.markdown(f'<a href="data:file/csv;base64,{uploaded_file.getvalue().encode().decode()}">Download CSV File</a>', unsafe_allow_html=True)
|
156 |
-
|
157 |
-
else:
|
158 |
-
st.write("Please upload a CSV file to begin.")
|
159 |
-
|
160 |
-
|
161 |
title = """<h1 align="center">Memory Chat Story Generator ChatGPT</h1>"""
|
162 |
description = """
|
163 |
## ChatGPT Datasets π
|
|
|
91 |
|
92 |
# Episodic and Semantic IO
|
93 |
def list_files(file_path):
|
|
|
94 |
icon_csv = "π "
|
95 |
icon_txt = "π "
|
96 |
current_directory = os.getcwd()
|
|
|
98 |
for filename in os.listdir(current_directory):
|
99 |
if filename.endswith(".csv"):
|
100 |
file_list.append(icon_csv + filename)
|
101 |
+
# Add download button for each CSV file
|
102 |
+
download_button = Download(label="Download", data=os.path.join(current_directory, filename), file_name=filename)
|
103 |
+
file_list.append(download_button)
|
104 |
elif filename.endswith(".txt"):
|
105 |
file_list.append(icon_txt + filename)
|
106 |
if file_list:
|
|
|
145 |
except:
|
146 |
return "Error occurred while appending to file."
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
title = """<h1 align="center">Memory Chat Story Generator ChatGPT</h1>"""
|
149 |
description = """
|
150 |
## ChatGPT Datasets π
|