-
Notifications
You must be signed in to change notification settings - Fork 2
/
chooseExtremeRowOnCol.py
executable file
·46 lines (33 loc) · 869 Bytes
/
chooseExtremeRowOnCol.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
from albertcommon import *
def printUsageAndExit(programName):
print >> stderr,"Usage: %s filename keycols criteriaCol <min|max>" %(programName)
exit(1)
selFuncs=dict()
def smaller(record,new):
return new<record
def larger(record,new):
return new>record
selFuncs["min"]=smaller
selFuncs["max"]=larger
if __name__='__main__':
programName=argv[0]
args=argv[1:]
try:
filename,keycols,criteriaCol,selectorFunc=args
except:
printUsageAndExit(programName)
fs="\t"
startRow=2
headerRow=1
#headerRow-=1
header,prestarts=getHeader(filename,headerRow,startRow,fs)
keycols=getCol0ListFromCol1ListStringAdv(header,keycols)
criteriaCol=getCol0ListFromCol1ListStringAdv(header,criteriaCol)[0]
fil=open(filename)
for lin in fil:
lin=lin.rstrip("\r\n")
if len(lin)<1:
continue
getSubvector(keycols)
fil.close()