-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRange categories.py
49 lines (35 loc) · 1.01 KB
/
Range categories.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
46
47
48
49
from pathlib import Path
import constants
import csv
"""
Checks that the file exists and if not, prints to screen.
Actions:
- supplier filename
- supplier dir
- image dir
"""
supplier_filename = 'The Range - The Range.csv'
path = constants.SUPP_PATH
infile = path + supplier_filename
with open(infile,'r',encoding='utf-8') as fin:
dr = csv.DictReader(fin)
cat_set = set()
catpath_set = set()
for row in dr:
cats = row['category_ /_sub category']
catlist = cats.split('|')
length = len(catlist)
for n in range(0,length):
#print (catlist[n])
if not catlist[n] in cat_set:
catpath_set.update([catlist[n].strip()])
tmp = catlist[n].split('/')
lengthtmp = len(tmp)
for n in range(0,lengthtmp):
if not tmp[n] in cat_set:
cat_set.update([tmp[n].strip()])
for s in catpath_set:
print (s)
print ('*****')
for s in cat_set:
print (s)