Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29895

Read emails from txt file using python

$
0
0

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

Viewing all articles
Browse latest Browse all 29895

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>