I need to extract a portion of text from a txt file.
The file looks like this:
STARTINGWORKIN DD / MM / YYYY HH: MM: SS
... text lines ...
... more text lines ...
STARTINGWORKING DD / MM / YYYY HH: MM: SS
... text lines I want ...
... more text lines that I want ...
- The file starts with STARTINGWORK and ends in text lines.
I need to extract the final text portion after the last STARTINGWORK, without the STARTINGWORK str
I tried use 3 for loops (one to start, another read the between line, and the last to end)
file = "records.txt"
if file.endswith (".txt"):
if os.path.exists (file):
lines = [line.rstrip ('\ n') for line in open (file)]
for line in lines:
#extract the portion