-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_load_save.py
More file actions
39 lines (29 loc) · 1.02 KB
/
data_load_save.py
File metadata and controls
39 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
import csv
def make_csv(data, new_csv_path):
with open(new_csv_path, 'a', encoding='utf-8-sig', newline='') as new_csv:
write_csv = csv.writer(new_csv)
write_csv.writerow(data)
new_csv.close()
def read_submission_csv(tmp_list, csv_path):
with open(csv_path, 'r', encoding='utf-8-sig') as read_csv:
read = csv.reader(read_csv)
for i in read:
tmp_list.append(i[1])
return tmp_list
def save_similarity_csv(data, new_csv_path):
with open(new_csv_path, 'a', encoding='utf-8-sig', newline='') as new_csv:
write_csv = csv.writer(new_csv)
write_csv.writerow(data)
new_csv.close()
def load_img_path(img_path, url):
try:
file_list = os.listdir(img_path + url)
# for i in file_list:
# if i[-3:-1] != 'jpg':
# file_list.remove(i)
# print("get img file name", file_list)
return file_list
except FileNotFoundError:
# print("Get_img_path : FileNotFoundError")
return "0"