Mercurial > repos > fubar > tool_factory_2
comparison toolfactory/test-data/runme.py @ 28:ad564ab3cf7b draft
Uploaded
author | fubar |
---|---|
date | Fri, 31 Jul 2020 23:00:31 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
27:c4e3cf28545f | 28:ad564ab3cf7b |
---|---|
1 # reverse order of columns in a tabular file | |
2 import argparse | |
3 parser = argparse.ArgumentParser() | |
4 a = parser.add_argument | |
5 a('--infile',default='') | |
6 a('--outfile',default=None) | |
7 a('--prefix',default=None) | |
8 args = parser.parse_args() | |
9 inp = args.infile | |
10 outp = args.outfile | |
11 i = open(inp,'r').readlines() | |
12 o = open(outp,'w') | |
13 for row in i: | |
14 rs = row.rstrip() | |
15 rs = list(rs) | |
16 rs.reverse() | |
17 o.write('%s:%s' % (args.prefix,''.join(rs))) | |
18 o.write('\n') | |
19 o.close() |