Skip to content

Instantly share code, notes, and snippets.

@KKarthikeya
Created August 16, 2015 04:29
Show Gist options
  • Save KKarthikeya/6c81b823e41bcc24a904 to your computer and use it in GitHub Desktop.
Save KKarthikeya/6c81b823e41bcc24a904 to your computer and use it in GitHub Desktop.
Open the file mbox-short.txt and read it line by line. When you find a line that starts with 'From ' like the following line: From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 You will parse the From line using split() and print out the second word in the line (i.e. the entire address of the person who sent the message). Then print out a …
count = 0
for mail in open(raw_input("Enter file name:")):
mail = mail.rstrip()
if mail.startswith("From "):
count +=1
words = mail.split()
print words[1]
print "There were",count,"lines in the file with From as the first word"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment