Mercurial > repos > jpayne > table_ops
comparison table-union.py @ 0:f1f2497301d3
planemo upload
author | jpayne |
---|---|
date | Mon, 08 Jan 2018 11:19:54 -0500 |
parents | |
children | 8c5fb0c5e560 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f1f2497301d3 |
---|---|
1 #!/usr/bin/env python3 | |
2 | |
3 import csv | |
4 import sys | |
5 | |
6 | |
7 | |
8 def main(files): | |
9 header = [] | |
10 items = [] | |
11 for fi in files: | |
12 with open(fi, 'rU') as table: | |
13 rows = csv.DictReader(table, delimiter='\t', dialect='excel-tab') | |
14 for field in rows.fieldnames: | |
15 if field not in set(header): | |
16 header.append(field) | |
17 items.extend(rows) | |
18 wr = csv.DictWriter(sys.stdout, delimiter='\t', dialect='excel-tab', fieldnames=header) | |
19 wr.writeheader() | |
20 wr.writerows(items) | |
21 | |
22 | |
23 if __name__ == '__main__': | |
24 main(sys.argv[1:]) |