#!/usr/bin/env python
#
# Give a quick summary of data which has been retrieved
#

import argparse
import json
from collections import Counter
from pprint import pprint

parser = argparse.ArgumentParser()
parser.add_argument("json_file", type=str, help="JSON data file from scraper")
args = parser.parse_args()

type_count = Counter()

infile = open(args.json_file, 'r')
for line in infile.readlines():
    try:
        data_obj = json.loads(line)
    except:
        pass
    type_count[data_obj['type']] += 1

pprint(dict(type_count))


@@ -161,16 +161,26 @@
 t pprint
+%0Aimport re
 %0A%0Aparser
@@ -338,16 +338,87 @@
 unter()%0A
+year_count = Counter()%0A%0Ayear_regex = re.compile('(?P%3Cyear%3E%5Cd%5Cd%5Cd%5Cd)')%0A%0A
 %0Ainfile 
@@ -590,24 +590,393 @@
  1%0A%0A
-pprint(dict(type
+    if data_obj%5B'type'%5D == 'HansardRecord':%0A        if data_obj.has_key('date'):%0A            print data_obj%5B'date'%5D.encode('utf-8')%0A            match = year_regex.search(data_obj%5B'date'%5D)%0A            year = int(match.groupdict()%5B'year'%5D)%0A            year_count%5Byear%5D += 1%0A        else:%0A            print %22NO DATE%22%0A            pprint(data_obj)%0A%0Apprint(dict(type_count))%0Apprint(dict(year
 _cou

Print count summaries for Hansard by year