Skip to content

Instantly share code, notes, and snippets.

@peterbe
Created January 28, 2015 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterbe/b857c7329ac23bef768d to your computer and use it in GitHub Desktop.
Save peterbe/b857c7329ac23bef768d to your computer and use it in GitHub Desktop.
import sys
logfile = sys.argv[1]
from collections import defaultdict
inserts = defaultdict(int)
for line in open(logfile):
inserts[line.strip()] += 1
items = [(v,k) for (k,v) in inserts.items()]
total = sum(x[0] for x in items)
items.sort()
items.reverse()
for times, query in items[:20]:
print str(times), query[:100]
print "TOTAL", total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment