0% found this document useful (0 votes)
3 views1 page

Email Domain Count Analysis

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Email Domain Count Analysis

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import

sqlite
3
conn = [Link]('[Link]')
cur = [Link]()
[Link]('DROP TABLE IF EXISTS Counts')
[Link]('CREATE TABLE Counts (org TEXT, count INTEGER)')
fname = input('Enter file name: ')
if len(fname) < 1:
fname = '[Link]'
fh = open(fname)
for line in fh:
if not [Link]('From: '):
continue
pieces = [Link]()
email = pieces[1]
org = [Link]('@')[1]
[Link]('SELECT count FROM Counts WHERE org = ?', (org, ))
try:
count = [Link]()[0]
[Link]('UPDATE Counts SET count = count + 1 WHERE org = ?',
(org, ))
except:
[Link]('INSERT INTO Counts (org, count) VALUES (?, 1)', (org, ))
[Link]()
sqlstr = 'SELECT org, count FROM Counts ORDER BY count DESC LIMIT 10'
for row in [Link](sqlstr):
print(row[0], row[1])
[Link]()

You might also like