]> git.treefish.org Git - phys/latscripts.git/blob - meanstep.py
64f28f0c49aa3a13781a17d29c906e52da9edfee
[phys/latscripts.git] / meanstep.py
1 #!/usr/bin/python
2
3 """ meanstep.py
4  ...
5 """
6
7 import sys
8 import os
9
10 results = {}
11
12 if len(sys.argv) != 4:
13     print "usage: ./meanstep.py <datadir> <matching col 1>,...,<matching col n> <mean col 1>,...,<mean col n>"
14     exit(0)
15
16 matchcols = sys.argv[2].split(",")
17
18 for root, dirs, filenames in os.walk(sys.argv[1]):
19     for f in filenames:
20         if f[-4:] != ".dat":
21             continue
22
23         with open(root + "/" + f) as inf:
24             for line in inf:
25                 if line[0:1] == "#":
26                     continue
27
28                 linecols = line.split()
29                 matchkey = ""
30                 for imatchcol in range(0,len(matchcols)):
31                     matchkey = matchkey + linecols[int(matchcols[imatchcol])]
32                 
33                 
34
35         #results[f[:-4]] = "tefds"