-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTDiffIntUnion.py
55 lines (46 loc) · 1.54 KB
/
TDiffIntUnion.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
50
51
52
53
54
#------------------------------------------------------------
#------------------------------------------------------------
# tdiu.py
#
#----------------------------------------------------------------------
from TableTool import TableTool
from common import *
#----------------------------------------------------------------------
#
class TDiffIntUnion( TableTool ):
def __init__(self,argv):
self.kcols1 = []
self.kcols2 = []
self.t2Keys = {}
TableTool.__init__(self,2,argv)
#---------------------------------------------------------
def initArgParser(self):
TableTool.initArgParser(self)
self.parser.add_option("--k1", dest="k1",
action="append", default = [],
metavar="COLUMN(S)",
help="Specifies key column(s) for table T1.")
self.parser.add_option("--k2", dest="k2",
action="append", default = [],
metavar="COLUMN(S)",
help="Specifies key column(s) for table T2.")
#---------------------------------------------------------
#
def processOptions(self):
TableTool.processOptions(self)
if len(self.options.k1) > 0:
self.kcols1 = self.parseIntList(self.options.k1)
if len(self.options.k2) > 0:
self.kcols2 = self.parseIntList(self.options.k2)
nkc1 = len(self.kcols1)
nkc2 = len(self.kcols2)
if nkc1 != nkc2:
self.parser.error("Same number of key columns must " + \
"be specified for both IDs.")
#---------------------------------------------------------
def makeKey(self, row, cols):
key = []
for c in cols:
v = row[c]
key.append( v )
return tuple(key)