Esempio n. 1
0
                # ignore the trailing + or - character.
                curItem.val = float(curItem.fields[0][:-1].replace(",", ""))
                buf = ''
                state = 2

        elif state == 2:
            if len(buf) == 0 and not c.isalpha():
                continue
            buf += c
            # if date found, start a new record
            if re.search('\d\d-\d\d ', buf):
                # save description to current record
                curItem.fields.append(buf[:-6])
                items.append(curItem)

                # start new record
                curItem = checklist.Item()
                dt = extractDate(buf)
                curItem.fields.append(dt)
                buf = ''
                state = 1

            # interest is always the last record
            elif 'Interest Earned' in buf:
                curItem.fields.append(buf)
                items.append(curItem)
                break

items.sort(key=lambda a: a.val)
checklist.generate("Bank of America", firstDate, lastDate, items)
Esempio n. 2
0
firstDate = None
lastDate = ""

for line in (i.strip() for i in fileinput.input()):
    if not line:
        continue

    i = checklist.Item()
    i.fields = line.split(",")

    # Get the range of dates. The input data is sorted by date, so the most
    # recently read line will have the last date.
    if firstDate is None:
        firstDate = i.fields[0]
    lastDate = i.fields[0]

    # Remove unneeded fields.
    del i.fields[1]
    del i.fields[3:]

    i.val = float(i.fields[1])

    # Make the dollar amount appear first.
    i.fields[0], i.fields[1] = i.fields[1], i.fields[0]

    items.append(i)

items.sort(key=lambda a: a.val)
items.reverse()
checklist.generate("American Express", firstDate, lastDate, items)
Esempio n. 3
0
                # ignore the trailing + or - character.
                curItem.val = float(curItem.fields[0][:-1].replace(",", ""))
                buf = ''
                state = 2

        elif state == 2:
            if len(buf) == 0 and not c.isalpha():
                continue
            buf += c
            # if date found, start a new record
            if re.search('\d\d-\d\d ', buf):
                # save description to current record
                curItem.fields.append(buf[:-6])
                items.append(curItem)

                # start new record
                curItem = checklist.Item()
                dt = extractDate(buf)
                curItem.fields.append(dt)
                buf = ''
                state = 1

            # interest is always the last record
            elif 'Interest Earned' in buf:
                curItem.fields.append(buf)
                items.append(curItem)
                break

items.sort(key=lambda a: a.val)
checklist.generate("Bank of America", firstDate, lastDate, items)
Esempio n. 4
0
import checklist
import fileinput

items = []
firstDate = None
lastDate = ""

for line in (i.strip() for i in fileinput.input()):
    i = checklist.Item()
    i.fields = line.split(',')

    # Get the range of dates. The input data is sorted by date, so the most
    # recently read line will have the last date.
    if firstDate is None:
        firstDate = i.fields[0]
    lastDate = i.fields[0]

    # The floating-point parser gets tripped up by the commas in dollar amounts
    # greater than 1000.  Rather than bother with locale stuff and parsing, I'm
    # stripping them out.  I also ignore the leading $ character.
    i.val = float(i.fields[1][1:].replace(",", ""))

    # Make the dollar amount appear first.
    i.fields[0], i.fields[1] = i.fields[1], i.fields[0]

    items.append(i)

items.sort(key=lambda a: a.val)
checklist.generate("Citi Mastercard", firstDate, lastDate, items)
Esempio n. 5
0
firstDate = None
lastDate = ""

for line in (i.strip() for i in fileinput.input()):
    if not line:
        continue

    i = checklist.Item()
    i.fields = line.split(',')

    # Get the range of dates. The input data is sorted by date, so the most
    # recently read line will have the last date.
    if firstDate is None:
        firstDate = i.fields[0]
    lastDate = i.fields[0]

    # Remove unneeded fields.
    del i.fields[1]
    del i.fields[3:]

    i.val = float(i.fields[1])

    # Make the dollar amount appear first.
    i.fields[0], i.fields[1] = i.fields[1], i.fields[0]

    items.append(i)

items.sort(key=lambda a: a.val)
items.reverse()
checklist.generate("American Express", firstDate, lastDate, items)