annotate toolfactory/test-data/runme.py @ 28:ad564ab3cf7b draft

Uploaded
author fubar
date Fri, 31 Jul 2020 23:00:31 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
1 # reverse order of columns in a tabular file
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
2 import argparse
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
3 parser = argparse.ArgumentParser()
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
4 a = parser.add_argument
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
5 a('--infile',default='')
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
6 a('--outfile',default=None)
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
7 a('--prefix',default=None)
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
8 args = parser.parse_args()
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
9 inp = args.infile
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
10 outp = args.outfile
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
11 i = open(inp,'r').readlines()
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
12 o = open(outp,'w')
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
13 for row in i:
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
14 rs = row.rstrip()
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
15 rs = list(rs)
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
16 rs.reverse()
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
17 o.write('%s:%s' % (args.prefix,''.join(rs)))
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
18 o.write('\n')
ad564ab3cf7b Uploaded
fubar
parents:
diff changeset
19 o.close()