I am not that experienced with Python, hence my request to help me improve my code.
I am trying to parse "Steve" which will be under the field "Name":
xxxx xxxx xxxx Name
zzzz zzzz zzzz Steve
my code looks like this:
for line in myfile.readlines():
[..]
if re.search(r'Name =', line):
print("Destination = ")
samples+=line[15:19]
nextline = "y"
if nextline == 'y':
samples+=line[15:19]
Eventually I will print everything:
[..]
for s in samples:
myfile2.write(s)
It does work, but I can't believe there is no smarter way to do this (like accessing to the following line once the conditions are met..).
This is an example of the file I need to parse. But the structure may vary as for instance
#This is another example
Name =
Steve
Any help is appreciated.