Grouping csv tallies by month with python

I have a CSV of the format:
id, name, datetime1, amount1, datetime2, amount2, datetime3, amount3, etc.

e.g.
10551,name1,2019-04-03 15:25,159.0,2019-04-03 15:25,159.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

10601,name2,2019-04-03 15:42,159.0,2019-04-03 15:42,159.0,2019-04-06 02:40,0.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

10651,name3,2019-04-03 15:43,159.0,2019-04-03 15:43,159.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

The amounts are running totals of the total billed for that client. Refunds and null amounts are included, so it might go in sequence 139, 139, 0 – These would equate to billing $139, then $0, then -$139. The dates corresponding to each billing event take place at any date, but I need to group the billing amount (not the total tally but the change) for each month, where a month is a 30-day interval (ideally, it would be on the same date of the next month that the grouping changes, but I’ll settle for 30-day intervals). The problem is that each row is of a different total length and the billing intervals are totally different from row to row. I believe that all of the rows include '' blank columns to pad to the same total length, but I tried to use the error to my advantage by creating exceptions. I’m looking for the first 12 months, where null amounts are 0.
Output should look like this:
id#, {1: month1_total, 2:month2_total, 3:month3_total, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0, 10:0, 11:0, 12:0} for a client with only 3 months’ data.

My code isn’t working and I don’t know why. It’s supposed to be iterating through at 30-day intervals and then moving forward a month number.

import csv
from datetime import datetime

infile = 'data.csv'
outfile = 'grouped.csv'

month = {}

with open(infile, 'r', encoding='utf8', errors='ignore') as inf, 
        open(outfile, 'w', encoding='utf8', errors='ignore', newline='') as outf:
    read = csv.reader(inf)
    out = csv.writer(outf)
    for row in read:
        try:
            pos = float(row(3))
        except:
            pos = 0
            print(row(3), 'pos')
            continue
        month(row(0)) = {}
        month(row(0))(1) = 0
        x = 2
        i = 1
        try:
            if row(4) == '':
                month(row(0))(1) = pos
                for i in range(2, 12):
                    month(row(0))(i) = 0
                continue
        except:
            month(row(0))(1) = pos
            for i in range(2, 12):
                month(row(0))(i) = 0
            continue
        month(row(0))(1) = pos
        for i in range(2, 12):
            month(row(0))(i) = 0
        # for i in range(12):
        month(row(0))(i) = pos
        days = 0
        i = 1
        while i <= 11:
            try:
                d1 = row(x).split(' ')(0).strip()
                d1 = datetime.strptime(d1, '%Y-%m-%d')
                d1_amount = float(row(x+1))
                d2 = row(x+2).split(' ')(0).strip()
                d2 = datetime.strptime(d2, '%Y-%m-%d')
                d2_amount = float(row(x+3))
                delta = d2 - d1
                delta_days = delta.days
                days += delta_days
                if days < 30:
                    month(row(0))(i) += (d2_amount - d1_amount)
                else:
                    i += 1
                    month(row(0))(i) += (d2_amount - d1_amount)
                    days = days - 30
                x += 2
            except Exception as e:
                i += 1
                month(row(0))(i) = 0
    for id_ in month:
        print(id_, month(id_))