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
|
import os
import os.path
import datetime
from datetime import date
import pdb
import csv
if os.name =='nt':
root = "//WDsentinel/share/CorpCDOs/Scenarios"
elif os.name == 'posix':
root = '/home/share/CorpCDOs/Scenarios'
input = os.path.join(root, "prometheus.sss")
for dealname in ["stonln1", "babs072", "flags5", "cent11", "wasatl", "oceant2", "acacl071", "limes"]:
output = os.path.join(root, dealname + ".sss")
cdrscenarios = os.path.join(root, dealname + "-cdr.csv")
recoveryscenarios = os.path.join(root, dealname + "-recovery.csv")
fh2 = open(output, "w")
fhcdr = open(cdrscenarios, "r")
fhrecovery = open(recoveryscenarios, "r")
cdrline = "\t".join(fhcdr.readline().rstrip().split(",")) +"\n"
recoveryline = "\t".join(fhrecovery.readline().rstrip().split(",")) + "\n"
i=1
with open(input) as fh:
for line in fh:
if "LOSS_RATE[DEAL,{0}]".format(i) in line:
newcdrline = "LOSS_RATE[DEAL,{0}]=".format(i) + cdrline
fh2.write(newcdrline)
continue
if "LOSS_SEVERITY[DEAL,{0}]".format(i) in line:
newrecoveryline = "LOSS_SEVERITY[DEAL,{0}]=".format(i) + recoveryline
fh2.write(newrecoveryline)
i=i+1
cdrline = "\t".join(fhcdr.readline().rstrip().split(",")) + "\n"
recoveryline = "\t".join(fhrecovery.readline().rstrip().split(",")) + "\n"
continue
fh2.write(line)
fh2.close()
fhrecovery.close()
fhcdr.close()
# sed -i -e "s/\(LOSS_NONPERF_SEVERITY\\[DEAL,[0-9]*\\]\)=.*$/\1=mkt(70)/g" stonln1_100.sss
|