-
Notifications
You must be signed in to change notification settings - Fork 0
/
createPickle.py
48 lines (40 loc) · 1.17 KB
/
createPickle.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
import networkx as nx
import collections
import csv
import pickle
mr_type = 'additive'
labelList = []
gList = []
gTestList = []
gTrainList = []
labelTrainList =[]
labelTestList = []
with open('./Labels/additive/additive_dataLabel_org_m1_m3_m4.csv', 'r') as csvFile:
reader = csv.reader(csvFile)
counter = 0
for row in reader:
print(row)
dotFile = row[0]
label = row[1]
filepath = './DotFiles/all/'
G = nx.drawing.nx_pydot.read_dot(str(filepath)+ str(dotFile))
#edge = nx.readwrite.edgelist.write_edgelist(G,str(counter)+".edgelist", data = False)
#for x in edge:
if counter > 35:
gTestList.insert(counter,G)
labelTestList.insert(counter,label)
else:
gTrainList.insert(counter,G)
labelTrainList.insert(counter,label)
gList.insert(counter,G)
counter = counter + 1
labelList.insert(counter,label)
#zipbObj = zip(gList, labelList)
#dataFile = dict(zipbObj)
#for (k,v) in dataFile.items():
#print(len(k.nodes),v)
nx.write_gpickle(gList, "./gPickles/additive/additive_org_m1_m3_m4.gpickle")
with open('./Labels/additive/final_labels/additive_org_m1_m3_m4.txt', 'w') as f:
for item in labelList:
f.write("%s\n" % item)
csvFile.close()