Last active
September 5, 2016 21:17
-
-
Save mmattice/1567e60553504a0934eb9eb908844cb7 to your computer and use it in GitHub Desktop.
Create a 5 minute bucket histogram of input apache-style timestamps
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 fileinput | |
from datetime import datetime | |
counts = dict() | |
for i in range(288): | |
counts[i] = 0 | |
for line in fileinput.input(): | |
dt = datetime.strptime(line.strip(), '%d/%b/%Y:%H:%M:%S') | |
bucket = (dt.hour*60+dt.minute)/5 | |
counts[bucket] += 1 | |
for k, v in counts.iteritems(): | |
print "%02i:%02i\t%i" % (k*5/60, k*5%60, v) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment