first of all, completely new to python, so this question might be easy.
I want to read a text file and save it as a new file, separate the header in emails from the body. The place where the header ends is the empty line under "X-UID: 81" (as seen in the image). Not all emails have the "X-UID:" so the empty line is the place where I want to separate it. Is there an easy way to do this?
My code currently looks like this:
with open("1.txt") as fReader:
corpus = fReader.read()
loc = corpus.find("X-UID")
print(corpus[:loc])
- This sort of works, but I can't separate at the empty line. And don't know how to save as new file