Skip to content

Commit bcca248

Browse files
Merge pull request #810 from swastik1308/master
Addition of email extraction program
2 parents 64d41a4 + 43273b5 commit bcca248

File tree

3 files changed

+1931
-0
lines changed

3 files changed

+1931
-0
lines changed

email id dictionary/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

email id dictionary/dict1.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
counts=dict()
2+
mails=list()
3+
fname=input('Enter file name:')
4+
fh=open(fname)
5+
for line in fh:
6+
if not line.startswith('From'):
7+
continue
8+
if line.startswith('From:'):
9+
continue
10+
id=line.split()
11+
mail=id[1]
12+
mails.append(mail)
13+
for x in mails:
14+
counts[x]=counts.get(x,0)+1
15+
bigmail=None
16+
bigvalue=None
17+
for key,value in counts.items():
18+
if bigvalue==None or bigvalue<value:
19+
bigmail=key
20+
bigvalue=value
21+
print(bigmail, bigvalue)

0 commit comments

Comments
 (0)