I have a text file like below. I would like to extract the rows below "Parameters------> up to See file nwirp_nsmc.sen for parameter sensitivities." and write in different text file. How can I do that?
OPTIMISATION RESULTS
Covariance matrix and parameter confidence intervals cannot be determined:-
Some form or regularisation was implemented so these are not applicable.
Use the PREDUNC7 utility to obtain a full posterior covariance matrix.
Parameters ----->
Parameter Estimated value
1.hklay1 3.278692E-06
2.kppt1 4.249307E-07
3.kppt2 2.849132E-06
-------
-------
See file nwirp_nsmc.sen for parameter sensitivities.
Observations ----->
This is what I tried but it is not working for my file. I know I am missing something here but I dont know now what is the missing part.
New extracting
inFile = open('nwirp-1.txt')
outFile = open('result2.txt', 'w')
new = []
Set = True
for line in inFile:
new.append(line)
if line.startswith("Parameters------>"):
#---- starts a new data set
if Set:
outFile.write("".join(new))
elif line.startswith("See file nwirp_nsmc.sen for parameter sensitivities."):
Set = False
new = []
inFile.close()
outFile.close()
startswith("**")and start there?