Created
October 13, 2015 13:13
-
-
Save anonymous/a727902cb2d669623fce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from datetime import datetime | |
key = "Subject: New scikit-learn questions" | |
path = '/Users/[ username ]/Library/Mail/[ mailboxname ]/INBOX.imapmbox/Messages/' | |
fnames = [p for p in os.listdir(path) if p.endswith('.emlx')] | |
times = [] | |
for i,fname in enumerate(fnames): | |
print i+1, "/", len(fnames) | |
with open(path+fname) as f: txt = f.read() | |
if key not in txt: continue | |
date = [line for line in txt.split('\n') if line.startswith('Date:')][0][6:-6] | |
date = datetime.strptime(date, "%a, %d %b %Y %H:%M:%S") | |
times.append(date) | |
times = sorted(times) | |
deltas = [(times[i+1]-times[i]).total_seconds() for i in range(len(times)-1)] | |
seconds_in_24h = 86400. | |
times2 = [(t.hour*3600 + t.minute*60 + t.second)/seconds_in_24h*24 for t in times] | |
import matplotlib.pyplot as plt | |
plt.plot(times2) | |
plt.ylabel('Hour of day recieved') | |
plt.xlabel('Newsletters sorted by date') | |
plt.savefig('./newsletters-times.png', bbox_inches='tight') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment