Skip to content

Addition of email extraction program #810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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