-
Notifications
You must be signed in to change notification settings - Fork 0
/
Supplier.py
42 lines (36 loc) · 1.1 KB
/
Supplier.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
import csv
import json
import ObjectNode
SupplierDict = dict()
# Init
god = ObjectNode.ObjectNode("god")
Sdate = god.ObjectPeer("Sdate")
Edate = god.ObjectPeer("Edate")
Company = god.ObjectPeer("Company")
CID = god.ObjectPeer("CID")
with open('testt.csv', newline='') as csvfile:
rows = csv.reader(csvfile)
flag = True # delete head
for row in rows:
if flag:
flag = False
continue
if row[10] not in SupplierDict:
SupplierDict[row[10]] = list()
Ingredient = ObjectNode.ObjectNode(row[4])
if row[6] != "":
row[6] = row[6].replace("/","")
Ingredient.AddHash(Sdate,row[6])
if row[7] != "":
row[7] = row[7].replace("/","")
Ingredient.AddHash(Edate,row[7])
if row[10] != "":
Ingredient.AddHash(Company,row[10])
if row[12] != "":
Ingredient.AddHash(CID,row[12])
SupplierDict[row[10]].append(Ingredient.ObjectHash)
#for x in SupplierDict:
# print(x,SupplierDict[x])
fw = open('supplier.json','w')
fw.write(json.dumps(SupplierDict))
fw.close()