Update app.py
Browse files
app.py
CHANGED
@@ -14,9 +14,19 @@ def get_image_path(img, name, image_type):
|
|
14 |
|
15 |
def update_csv_file(uploaded_file, name, image_type):
|
16 |
csv_file_path = "Resources.csv"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
with open(csv_file_path, mode='a', newline='') as csv_file:
|
18 |
csv_writer = csv.writer(csv_file)
|
19 |
-
csv_writer.writerow(
|
20 |
|
21 |
def get_uploaded_files_info():
|
22 |
csv_file_path = "Resources.csv"
|
|
|
14 |
|
15 |
def update_csv_file(uploaded_file, name, image_type):
|
16 |
csv_file_path = "Resources.csv"
|
17 |
+
line_to_add = [name, uploaded_file.name, image_type]
|
18 |
+
with open(csv_file_path, mode='r') as csv_file:
|
19 |
+
existing_lines = csv_file.readlines()
|
20 |
+
|
21 |
+
# Check if the line to add already exists
|
22 |
+
for line in existing_lines:
|
23 |
+
if line.strip() == line_to_add:
|
24 |
+
return
|
25 |
+
|
26 |
+
# If the line does not exist, add it to the file
|
27 |
with open(csv_file_path, mode='a', newline='') as csv_file:
|
28 |
csv_writer = csv.writer(csv_file)
|
29 |
+
csv_writer.writerow(line_to_add)
|
30 |
|
31 |
def get_uploaded_files_info():
|
32 |
csv_file_path = "Resources.csv"
|