|
|
|
@ -54,17 +54,14 @@ class Relation (object):
|
|
|
|
|
|
|
|
|
|
def __init__(self, filename=""):
|
|
|
|
|
self._readonly = False
|
|
|
|
|
self.content = set()
|
|
|
|
|
|
|
|
|
|
if len(filename) == 0: # Empty relation
|
|
|
|
|
self.content = set()
|
|
|
|
|
self.header = Header([])
|
|
|
|
|
return
|
|
|
|
|
with open(filename) as fp:
|
|
|
|
|
reader = csv.reader(fp) # Creating a csv reader
|
|
|
|
|
self.header = Header(next(reader)) # read 1st line
|
|
|
|
|
self.content = set()
|
|
|
|
|
attributes = len(self.header)
|
|
|
|
|
|
|
|
|
|
iterator = ((self.insert(i) for i in reader))
|
|
|
|
|
deque(iterator, maxlen=0)
|
|
|
|
|
|
|
|
|
@ -88,8 +85,7 @@ class Relation (object):
|
|
|
|
|
format as defined in RFC4180.
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
fp = open(filename, 'w') # Opening file in write mode
|
|
|
|
|
|
|
|
|
|
with open(filename, 'w') as fp:
|
|
|
|
|
writer = csv.writer(fp) # Creating csv writer
|
|
|
|
|
|
|
|
|
|
# It wants an iterable containing iterables
|
|
|
|
@ -98,7 +94,6 @@ class Relation (object):
|
|
|
|
|
|
|
|
|
|
# Writing content, already in the correct format
|
|
|
|
|
writer.writerows(self.content)
|
|
|
|
|
fp.close() # Closing file
|
|
|
|
|
|
|
|
|
|
def _rearrange(self, other):
|
|
|
|
|
'''If two relations share the same attributes in a different order, this method
|
|
|
|
|