I have a txt file that looks something like this:
=-=-=-=-=-=-=-=-=-=-=\n
data report
=-=-=-=-=-=-=-=-=-=-=\n
\n
\n
=-=-=-=-=-=-=-=-=-=-=\n
data report
=-=-=-=-=-=-=-=-=-=-=\n
\n
\n
…and so forth
I want to be able to extract each data report and do a variety of things to it (such as print a specific # that sits as a key value in some other dictionary I have, write it to another file, etc.). How would I go about doing this? I’ve been trying to learn Regex to help out, but it’s been confusing as I’m new to python, please help!
You can read the entire file into a string, split on the =-=-=… string, and strip the leading and trailing whitespace off of your reports like this: