Skip to content

Instantly share code, notes, and snippets.

View l1onk1ngl's full-sized avatar

Mohamed Medhat Rabeaey l1onk1ngl

View GitHub Profile
@zcakzwa
zcakzwa / gist:2bf34f782db0c43847250b5fa86bc2bf
Created July 5, 2016 12:43
10.2 Write a program to read through the mbox-short.txt and figure out the distribution by hour of the day for each of the messages. You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon. From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 Once you have accumulated the c…
name = raw_input("Enter file:")
if len(name) < 1 : name = "mbox-short.txt"
handle = open(name)
d=dict()
for line in handle:
if not line.startswith("From "):
continue
else:
line=line.split()
line=line[5]
@MichelleDalalJian
MichelleDalalJian / py4e_ex_09_04
Created October 7, 2017 14:43
9.4 Write a program to read through the mbox-short.txt and figure out who has the sent the greatest number of mail messages. The program looks for 'From ' lines and takes the second word of those lines as the person who sent the mail. The program creates a Python dictionary that maps the sender's mail address to a count of the number of times th…
fname = input("Enter file:")
if len(fname) < 1 : name = "mbox-short.txt"
hand = open(fname)
lst = list()
for line in hand:
if not line.startswith("From:"): continue
line = line.split()
lst.append(line[1])