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]()