awacke1 commited on
Commit
0c1eb0f
·
1 Parent(s): 5ec2618

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -32
app.py CHANGED
@@ -14,27 +14,12 @@ 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
- 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"
33
- if not os.path.exists(csv_file_path):
34
- with open(csv_file_path, mode='w', newline='') as csv_file:
35
- csv_writer = csv.writer(csv_file)
36
- csv_writer.writerow(['Name', 'File Name', 'Type'])
37
-
38
  with open(csv_file_path, mode='r') as csv_file:
39
  csv_reader = csv.reader(csv_file)
40
  files_info = []
@@ -88,19 +73,3 @@ while True:
88
  time.sleep(20)
89
  st.empty()
90
  display_images_from_csv()
91
-
92
- csv_file_path = "Resources.csv"
93
- with open(csv_file_path, mode='r') as f:
94
- rows = list(csv.reader(f))
95
-
96
- # show the csv file
97
- if rows:
98
- headers = ["Name", "File Name", "Image Type"]
99
- rows.insert(0, headers)
100
- table = "|".join(headers) + "|\n"
101
- table += "|".join(['---'] * len(headers)) + "|\n"
102
- for row in rows[1:]:
103
- table += "|".join(row) + "|\n"
104
- st.markdown(table)
105
- else:
106
- st.write("No files found.")
 
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([name, uploaded_file.name, image_type])
20
 
21
  def get_uploaded_files_info():
22
  csv_file_path = "Resources.csv"
 
 
 
 
 
23
  with open(csv_file_path, mode='r') as csv_file:
24
  csv_reader = csv.reader(csv_file)
25
  files_info = []
 
73
  time.sleep(20)
74
  st.empty()
75
  display_images_from_csv()