from collections import Counter
import json
from pprint import pprint
with open('logs.txt') as infile:
data = (json.loads(line) for line in infile)
counter = Counter((row['type'], row['key']) for row in data)
pprint(dict(counter))
Output:
{(u'REVERSEGEOCODE', u'04track12netics2015'): 5,
(u'REVERSEGEOCODE', u'fpOgtLY1ZF22m3va4FLkU52tsLmpaNyo'): 1,
(u'SEARCH', u'fpOgtLY1ZF22m3va4FLkU52tsLmpaNyo'): 1,
(u'TILE', u'CxIQlYBhwykcIxtYwrrbltCDiJ4xUxfN'): 3,
(u'TILE', u'fpOgtLY1ZF22m3va4FLkU52tsLmpaNyo'): 4}
1
solved Counting how many times a value occurs in a json file [closed]