#! /usr/bin/python

import time

raw = open('out')
months = []
for line in raw:
    date, bugs = line.split(':')
    bugs = bugs.split()
    year, month, day = date.split('-')
    monthid = '%s-%s' % (year, month)
    if months and months[-1][0] == monthid:
        months[-1][1] += len(bugs)
    else:
        months.append([monthid, len(bugs)])
raw.close()

stats = open('bugstats.data', 'w')
for monthid, bugcount in months:
    print >>stats, '%d, %d' % (time.mktime(time.strptime(monthid, '%Y-%m')),
                               bugcount)
stats.close()
