#!/usr/bin/python import sys import ra def union(theOne, theOther): if not theOne.unionCompatible(theOther): raise TypeError, "%s is not union compatible with previous input." % a answer = ra.Relation() answer.attributes = theOne.attributes answer.data = theOne.data.union(theOther.data) return answer def newRelationFromFile(theFileName): f = None if "-" == theFileName: f = sys.stdin else: f = open(theFileName) return ra.newRelationFromTSV(f) if __name__ == "__main__": answer = ra.Relation() if len(sys.argv) < 2: answer = newRelationFromTSV(sys.stdin) else: answer = newRelationFromFile(sys.argv[1]) for a in sys.argv[2:]: r = newRelationFromFile(a) answer = union(answer, r) answer.toTSV()