-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_csv.py
45 lines (33 loc) · 1.34 KB
/
create_csv.py
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
38
39
40
41
42
43
44
45
import os
from utils.image_proces import process_img
def create_csv(): # creación del csv para poder utilizar las imagenes
mypath = 'abecedario'
file_name = open('abecedario.csv', 'a')
for each_folder in os.listdir(mypath):
if '._' in each_folder:
pass
else:
for each_number in os.listdir(mypath + '/' + each_folder):
if '._' in each_number:
pass
else:
label = each_folder
file_loc = mypath + '/' + each_folder + '/' + each_number
data = process_img(file_loc)
try:
for id,i in enumerate(data):
if id == 0:
print(i)
file_name.write(str(i))
file_name.write(',')
file_name.write(label)
file_name.write('\n')
except:
file_name.write('0')
file_name.write(',')
file_name.write('None')
file_name.write('\n')
file_name.close()
print('CSV Created')
if __name__ == "__main__":
create_csv()