-
Notifications
You must be signed in to change notification settings - Fork 0
/
TUnion.py
34 lines (30 loc) · 978 Bytes
/
TUnion.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
#----------------------------------------------------------------------
#----------------------------------------------------------------------
#
# tu.py
#
'''
tu - table union
Outputs all rows of table1 followed by
all rows of table2 not in table 1, based on a key.
(No assumptions are made about union-compatability, i.e., the tables
are not required to have the same columns.)
'''
#----------------------------------------------------------------------
from TDiffIntUnion import TDiffIntUnion
from common import *
class TUnion (TDiffIntUnion):
USAGE=__doc__
def __init__(self,argv):
TDiffIntUnion.__init__(self,argv)
#---------------------------------------------------------
def go(self):
keys = {}
for row in self.t1:
key = self.makeKey(row, self.kcols1)
keys[key] = 1
yield row
for row in self.t2:
key = self.makeKey(row, self.kcols2)
if not keys.has_key(key):
yield row