I have a series of text files with formatting as follows
Transaction Summary
Joe buys from Mindy 5 apples for 6$
Mark buys from Alex 3 apples for 5$
...
END
Where there can be a variable amount of apple transactions--one text file might have 2 others might have 6--but the files are all formatted the same. I want to essentially store the lines between Transaction Summary and End.
I first consulted this method which allowed me to print said lines, but I couldn't figure out how to store the lines.
Instead I decided to just read the entire text file and store then and then trim the data I need
with open(filename) as f:
data = f.readlines()
f.close
This way I could splice this list of strings. The issue I'm having is that while I know where to start the splice (the 1 row index), since each text file has a variable amount of transactions, I don't know how to choose the specific index that has the "END" string in it.
Any input would be appreciated--thanks!