Skip to content

Instantly share code, notes, and snippets.

@manichabba
Created August 6, 2016 19:10
Show Gist options
  • Save manichabba/8782657c331909c70a03c312a831a5c0 to your computer and use it in GitHub Desktop.
Save manichabba/8782657c331909c70a03c312a831a5c0 to your computer and use it in GitHub Desktop.
name = raw_input("Enter file:")
if len(name) < 1 : name = "mbox-short.txt"
handle = open(name)
hour = list()
count = dict()
for line in handle:
if not line.startswith("From ") : continue
time = line.split()[5]
hour.append(time.split(":")[0])
for key in hour:
count[key]=count.get(key,0) + 1
for k,v in sorted(count.items()):
print k,v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment