pawelad / pymonzo

Modern Python API client for Monzo public API.
https://pymonzo.pawelad.dev/
Mozilla Public License 2.0
21 stars 20 forks source link

Question: Help with exporting information to CSV #7

Closed delabere closed 6 years ago

delabere commented 6 years ago

I have this code to export a CSV:

    import csv

from pymonzo import MonzoAPI

if __name__ == '__main__':
    monzo_api = MonzoAPI()
    monzo_transactions = monzo_api.transactions()

    with open('monzo_transactions.csv', 'w') as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow([
                'transaction.amount', 'transaction.description', 'transaction.created',
            ])

        for transaction in monzo_transactions:
            writer.writerow([
                transaction.amount, transaction.description, transaction.created,
            ])

    print('MONZO DATA SAVED!')

I also want to get my balance at the date of the transaction. Really for the purposes of this project all I need are [DATE] and [BALANCE] columns.

I can see that balance is part of the transaction information under 'account_balance' but I can't seem to just add it like with the others in the code.

Any ideas?

I apologise if I should not be putting these questions in the issues section.

Thanks.

delabere commented 6 years ago

I figured it out simply by adding the columns transaction.account_balance.

pawelad commented 6 years ago

Somehow related - I'm also planning to add this feature to monz (pawelad/monz#5).