-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAppendOutFile.py
executable file
·51 lines (50 loc) · 1.82 KB
/
AppendOutFile.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
47
48
49
50
51
#!/usr/bin/env python
import sys
if len(sys.argv) < 3:
print("Error: AppendOutFiles.py result.out first.out [second.out] ...")
sys.exit(1)
outFile=open(sys.argv[1],'w')
f1=open(sys.argv[2])
lineNumber=0
maxIndex=0
for line in f1:
outFile.write(line)
lineNumber+=1
if (lineNumber > 3):
vals=line.split()
index=vals[-1]
if index == "*":
index=vals[-2]
index=int(index)
if index > maxIndex:
maxIndex=index
curIndex=maxIndex+1
dataFiles=open(sys.argv[3])
dotOuts=[l.strip() for l in dataFiles.readlines()]
for other in dotOuts:
f=open(other)
lineNumber=0
for line in f:
lineNumber +=1
if lineNumber > 3:
vals=line.split()
index=vals[-1]
if index == "*":
if len(vals) != 16:
continue
index=vals[-2]
index=int(index)
index+=curIndex
if (len(vals) < 14):
print("ERROR with line")
print(line)
print(other)
sys.exit(1)
newLine="{:>5} {:>7.1f} {:>5.1f} {:>5.1f} {} {:>9} {:>8} {:>10} {:1} {:8} {:>23} {:>10} {:>7} {:>8} {:>10d}".format(int(vals[0]), float(vals[1]), float(vals[2]), float(vals[3]),
vals[4], vals[5], vals[6], vals[7], vals[8],
vals[9], vals[10], vals[11], vals[12],
vals[13], index)
if (vals[-1] == "*"):
newLine+= " *"
newLine += "\n"
outFile.write(newLine)