comparison column_arrange.py @ 0:f18f67056946 draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/text_processing/column_arrange_by_header commit 088e73e958b55dc765778641b8a84080cc289f85-dirty
author bgruening
date Fri, 16 Oct 2015 14:31:13 -0400
parents
children 6c6d26ff01ff
comparison
equal deleted inserted replaced
-1:000000000000 0:f18f67056946
1 #!/usr/bin/env python
2 import pandas as pd
3 import argparse
4
5 parser = argparse.ArgumentParser()
6 parser.add_argument('-i', '--input', help='Tabular Input File Name')
7 parser.add_argument('-o','--output', help='Tabular Output File')
8 parser.add_argument('-c', '--columns', nargs='+', help='Column Headers to Sort By')
9 args=parser.parse_args()
10
11 cols = args.columns
12 table = pd.read_csv(args.input, sep='\t')
13 blist = list(table.columns)
14 for token in cols:
15 blist.remove(token)
16 sorted_table = table[args.columns + blist]
17 # write without index, seperated by tabs
18 sorted_table.to_csv(args.output, sep='\t', index=False)