My input string from a file is ANG 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 My required output should be 0.0 0.0 0.0 0.0 0.0 0.0 100 0.3 But Now my input is same as output .The last two zeroes under ANG string to be replaced as 100.0 and 0.3 respectively.Please help me to get the required output.
What I have tried:
import re
class Calculate:
def angCal(self,direction,magnitude,string):
cnt=0
if cnt<=6:
f4.write(string)
cnt+=1
elif cnt==7:
string=str(direction)+"\n"
f4.write(string)
cnt += 1
elif cnt==8:
string = str(magnitude) + "\n"
f4.write(string)
cnt += 1
elif cnt==9:
cnt += 1
angFlag=0
angcnt=0
f1=open("nominal.txt","r")
f4=open("pp.txt","w")
obj=Calculate()
for line in f1.readlines():
string=line
if re.match(r'ANG',string):
angFlag=1
f4.write(string)
elif angFlag==1 and angcnt==0:
0 Answer(s)