Guest User

Untitled

a guest
May 23rd, 2015
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. fname = raw_input("Enter file name: ")
  2. if len(fname) < 1 : fname = "mbox"
  3. fh = open(fname)
  4. dic = dict()
  5. for line in fh:
  6.     line.rstrip()
  7.     if not line.startswith('From '):
  8.         continue
  9.     else:
  10.         words = line.split()
  11.         time = words[5]
  12.         q = ':'
  13.         t = time.split(q)
  14.         hours = t[:1]
  15.         for cnt in hours:
  16.             dic[cnt] = dic.get(cnt,0) + 1
  17.  
  18. lst = list()
  19. for (k,v) in dic.items():
  20.     lst.append( (k,v) )
  21. print lst
Advertisement
Add Comment
Please, Sign In to add comment