I need to extract values from the text file below:
fdsjhgjhg
fdshkjhk
Start
Good Morning
Hello World
End
dashjkhjk
dsfjkhk
The values I need to extract are from Start to End.
with open('path/to/input') as infile, open('path/to/output', 'w') as outfile:
copy = False
for line in infile:
if line.strip() == "Start":
copy = True
elif line.strip() == "End":
copy = False
elif copy:
outfile.write(line)
The code above I am using is from this question: Extract Values between two strings in a text file using python
This code will not include the strings "Start" and "End" just what is inside them. How would you include the perimeter strings?