-
Notifications
You must be signed in to change notification settings - Fork 1
/
notes.txt
165 lines (137 loc) · 5.13 KB
/
notes.txt
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
How to run -
1. Open the folder where you have all the files stored.
2. Right click and open terminal/ command prompt.
3. Type:
python main.py (path-to-images-folder) (option-number)
col_G:
1. Get all the matching names. - DONE
2. While making return list, just check if it is in matching list. - DONE
# def col_g(colData, _sku, names, max, inventory_csv_path):
# with open(inventory_csv_path, "r") as file:
# data = list(csv.reader(file))
# data1 = data[0]
# # app_list = []
# colData = read_csv(inventory_csv_path)
# col_G = colData[data1[6]].tolist()
# col_H = colData[data1[7]].tolist()
# col_I = colData[data1[8]].tolist()
# match = []
# real_match = []
# match_g = []
# for _ in range(len(col_G)):
# match_g.append("")
# # get unique from list
# # for _ in range(len(col_I)):
# # app_list.append('')
# particular_names = reduce(lambda re, x: re+[x] if x not in re else re, names, [])
# for name in names:
# name_index = []
# g_index = []
# sku_index = []
# for idx, value in enumerate(col_H):
# if(value.lower() == name.lower()):
# name_index.append(idx)
# for idx, value in enumerate(col_I):
# if(value.lower() == _sku.lower()):
# sku_index.append(idx)
# match = list(set(name_index).intersection(sku_index))
# # print(match)
# if match not in real_match:
# real_match.append(match)
# for idx, value in enumerate(col_G):
# g_index.append(idx)
# match = list(set(g_index).intersection(match))
# # getting the matches indexes
# for i in real_match:
# for j in i:
# match.append(j)
# # Find out if the name got match.
# match.sort()
# print("Matches list - ",match)
# for i in match:
# pass
# return (match_g[:max])
def old_g(colData, _sku, names, max, inventory_csv_path):
with open(inventory_csv_path, "r") as file:
data = list(csv.reader(file))
data1 = data[0]
app_list = []
colData = read_csv(inventory_csv_path)
col_G = colData[data1[6]].tolist()
col_H = colData[data1[7]].tolist()
col_I = colData[data1[8]].tolist()
match = []
real_match = []
match_g = []
for _ in range(len(col_G)):
match_g.append("")
# get unique from list
for _ in range(len(col_I)):
app_list.append('')
particular_names = reduce(lambda re, x: re+[x] if x not in re else re, names, [])
for name in names:
name_index = []
g_index = []
sku_index = []
for idx, value in enumerate(col_H):
if(value.lower() == name.lower()):
name_index.append(idx)
for idx, value in enumerate(col_I):
if(value.lower() == _sku.lower()):
sku_index.append(idx)
match = list(set(name_index).intersection(sku_index))
# print(match)
if match not in real_match:
real_match.append(match)
for idx, value in enumerate(col_G):
g_index.append(idx)
match = list(set(g_index).intersection(match))
corresponding_values = [col_G[i] for i in match]
for index, i in enumerate(match):
match_g[i] = int(corresponding_values[index])
# *****Done with matching part*****
number = 0
for index,i in enumerate(match_g):
if isinstance(i, int):
continue
else:
match_g[index] = match_g[index-1]
# getting the matches indexes
for i in real_match:
for j in i:
match.append(j)
# Find out if the name got match.
match.sort()
print(match)
for i in match:
pass
return (match_g[:max])
def new_col_G(colData, names, inventory_csv_path):
with open(inventory_csv_path, "r") as file:
data = list(csv.reader(file))
data1 = data[0]
colData = read_csv(inventory_csv_path)
ret_list = ["" for _ in names]
col_G = colData[data1[6]].tolist() # inventory numbers col
col_H = colData[data1[7]].tolist() # names columns
col_I = colData[data1[8]].tolist() # sku columns
# remove the doubles from list
particular_names = reduce(lambda re, x: re+[x] if x not in re else re, names, [])
names_in_inventory_col_H_with_index = []
for name in particular_names:
# Matching the names and getting their index
for index,lower_col_H in enumerate(col_H):
if (name.lower() == lower_col_H.lower()
and col_I[index] == sku_letters
and name not in names_in_inventory_col_H_with_index):
names_in_inventory_col_H_with_index.append([name,col_G[index]])
# print(names_in_inventory_col_H_with_index)
# preparing return list
for index, _ in enumerate(names_in_inventory_col_H_with_index):
try:
ret_list[names_in_inventory_col_H_with_index[index][1]] = str(24)
ret_list[names_in_inventory_col_H_with_index[index+1][1]] = str(24)
except:
pass
# print(ret_list)
return ret_list