Update app.py
Browse files
app.py
CHANGED
|
@@ -19,20 +19,6 @@ def list_files(file_path):
|
|
| 19 |
else:
|
| 20 |
return "No .csv or .txt files found in the current directory."
|
| 21 |
|
| 22 |
-
|
| 23 |
-
# Function to list files with .csv and .txt extensions in the current directory
|
| 24 |
-
def list_filesold(file_path):
|
| 25 |
-
import os
|
| 26 |
-
current_directory = os.getcwd()
|
| 27 |
-
file_list = []
|
| 28 |
-
for filename in os.listdir(current_directory):
|
| 29 |
-
if filename.endswith(".csv") or filename.endswith(".txt"):
|
| 30 |
-
file_list.append(filename)
|
| 31 |
-
if file_list:
|
| 32 |
-
return "\n".join(file_list)
|
| 33 |
-
else:
|
| 34 |
-
return "No .csv or .txt files found in the current directory."
|
| 35 |
-
|
| 36 |
# Function to read a file
|
| 37 |
def read_file(file_path):
|
| 38 |
try:
|
|
@@ -77,12 +63,12 @@ with demo:
|
|
| 77 |
completedMessage = gr.Textbox(label="Completed")
|
| 78 |
|
| 79 |
label = gr.Label()
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
|
| 87 |
listFiles.click(list_files, inputs=fileName, outputs=fileContent)
|
| 88 |
readFile.click(read_file, inputs=fileName, outputs=fileContent)
|
|
|
|
| 19 |
else:
|
| 20 |
return "No .csv or .txt files found in the current directory."
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
# Function to read a file
|
| 23 |
def read_file(file_path):
|
| 24 |
try:
|
|
|
|
| 63 |
completedMessage = gr.Textbox(label="Completed")
|
| 64 |
|
| 65 |
label = gr.Label()
|
| 66 |
+
with gr.Row():
|
| 67 |
+
listFiles = gr.Button("๐ List CSV and TXT File(s)")
|
| 68 |
+
readFile = gr.Button("๐ Read File")
|
| 69 |
+
saveFile = gr.Button("๐พ Save File")
|
| 70 |
+
deleteFile = gr.Button("๐๏ธ Delete File")
|
| 71 |
+
appendFile = gr.Button("โ Append File")
|
| 72 |
|
| 73 |
listFiles.click(list_files, inputs=fileName, outputs=fileContent)
|
| 74 |
readFile.click(read_file, inputs=fileName, outputs=fileContent)
|