I have test results in a log file that are formatted like:
useless info
useless info
======================
useful info
useful info
======================
test success
The number of lines in each section can vary, so I want to check for the first appearance of the double equal character ‘==’ and read that line until the end of the file into a string. Currently I’m using the following code to read the whole file into the string.
with open ("Report.txt", "r") as myfile:
data = myfile.read()
Thanks for the help!
I would however prefer to hide it away in a generator, like this:
All the filtering and nitpicking is done in the generator function, and you can separate the logic of “filtering input” from the logic of “working with the input”.