Skip to content

Commit

Permalink
Merge pull request geekcomputers#810 from swastik1308/master
Browse files Browse the repository at this point in the history
Addition of email extraction program
  • Loading branch information
geekcomputers authored Sep 13, 2020
2 parents 64d41a4 + 43273b5 commit bcca248
Show file tree
Hide file tree
Showing 3 changed files with 1,931 additions and 0 deletions.
1 change: 1 addition & 0 deletions email id dictionary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Write a program to read through the mbox-short.txt and figure out who has 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 they appear in the file. After the dictionary is produced, the program reads through the dictionary using a maximum loop to find the most prolific committer.
21 changes: 21 additions & 0 deletions email id dictionary/dict1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
counts=dict()
mails=list()
fname=input('Enter file name:')
fh=open(fname)
for line in fh:
if not line.startswith('From'):
continue
if line.startswith('From:'):
continue
id=line.split()
mail=id[1]
mails.append(mail)
for x in mails:
counts[x]=counts.get(x,0)+1
bigmail=None
bigvalue=None
for key,value in counts.items():
if bigvalue==None or bigvalue<value:
bigmail=key
bigvalue=value
print(bigmail, bigvalue)
Loading

0 comments on commit bcca248

Please sign in to comment.