I have a TXT file with emails, like:
From r Wed Oct 30 21:41:56 2002Return ......From r Thu Oct 31 08:11:39 2002Return ......
I want to extract each email into an array, like:
["From r Wed Oct 30 21:41:56 2002 Return ...", "From r Thu Oct 31 08:11:39 2002 Return ...", ..., "From r ..."]
I am using python
with open(self.file, encoding="utf8", errors='ignore') as data_file: lines = '' first_line = True for line in data_file: if line.startswith("From r") and not first_line: emails.append(lines) lines = '' else: first_line = False lines = lines + line