The ability to manage money is among the most powerful skills for improving your quality of life that is solely dependent on your behavior. However, understanding your past behavior without detailed records is essentially impossible. To this end, accounting is properly defined as a record of the transactions that have occurred in the past (as opposed to budgeting, which is a plan for transactions to occur in the future). What we are discussing here is an accounting script I wrote in both Python and JavaScript. The Python is on GitLab. The JavaScript is on my blog where the graphs are powered by D3.
This project is sentimental to me for a couple reasons. It was my first project in Python. It was my first project using all sorts of basic programming tropes like recursion and classes. I have rewritten these scripts six or seven times in the last 15 years. The early versions were rough as all early versions are, especially when part of the challenge is learning new complex tools (in this case, basic programming). It is also the software that runs my life to this day. The software has evolved greatly; the conceptual architecture (read a CSV with 5 columns and write a report) is unchanged since the first version in 2012. I have a record in this CSV file of every financial transaction I have partaken in since January 1st, 2013. That CSV file is 22,000 lines long as of September, 2026, with 21,500 transactions (there are a few hundred lines of comments as well).
The basic idea
Longer explanation of accounting is on my blog.
Double-entry accounting is the term for designing an accounting system where all transactions are recorded once and apply to two different accounts. For example, in the CSV text below, $58.13 was spent at Kroger and this money moved from the amex account (a credit card), to the grocery account (a spending category). Some accounts store wealth or debts (bank accounts, credit cards, loan accounts for autos and houses); some are spending categories (healthcare, transportation, housing, etc); some are income (day job, side jobs, rent from a rental property, etc); and some are just containers which store other accounts as sub accounts (net worth, all spending categories, all income, etc).
My Python script takes a 5 column CSV shown below and generates reports.
date,description,value,from,to 2026-01-05,Kroger,58.13,amex,groc
From this CSV, my scripts produce a number of important outputs:
- A profit and loss statement for the current month (or any other month by passing an argument).
- A breakdown of net worth by category (no transactions, just account totals).
- The current balance of any wealth or debt category along with recent transactions. Important for reconciling my records with the bank's records.
-
My savings rate for the month/
year/ arbitrary time period. -
All of these reports with certain transactions filtered by keywords in the description, either as must include X or cannot include X. Useful for removing large irregular purchases. For example, what would my savings rate be this month if I had not bought a car. Also useful to run a profit/
loss report to only include a keyword. This allows me to put 'SCOTTYWEDDING' in every related transaction. A report with that filter will show how much was spent attending Scott's wedding regardless of whether it was in the restaurant, transportation, or miscellaneous spending categories. -
Graph of various measures of net worth over time. My default plot is five lines on one graph:
- Cash and cards - just the balance of the checking accounts and credit cards. Important on a week to week basis to manage cash flows.
- Liquid net worth - everything I own that is not real estate or retirement accounts. This is just the cash and cards above plus non-retirement brokerage accounts and savings accounts.
- Liquid net worth plus primary residence - this is the cash I would have if I sold my home. It is only a particularly useful measurement if you want to sell your home to buy a different one as this is the financial picture you are working with to make that decision.
- Total net worth minus primary residence - this is the line which determines proximity to financial independence. If you own the home you live in, it is not an investment asset so you have to plan your future spending not including that piece of net worth. This does include retirement accounts and investment properties.
- Total net worth - everything: cash, investment properties, home equity, retirement accounts, etc
- Bar graph of spending in a category by month. For example, grocery bill over time.
Simulated financial data below shows an example report produced by my account software. Like the graph above, I see a similar report with real data on a daily to weekly basis to help me make decisions.
Balance (29,0)
Expenses (23,0)
Housing (6)
2020-02-01 Electric bill ........................ 73.23
2020-02-01 Rent on apartment .................... 1050.00
2020-02-10 Internet ISP ......................... 63.19
2020-02-10 Phone bill ........................... 85.33
2020-02-10 Renters insurance .................... 16.62
2020-02-10 Water bill ........................... 12.49
Total ................................ 1300.86
Healthcare
2020-02-13 Health insurance premiums ............ 164.33
Total ................................ 164.33
Auto/Transportation (6)
2020-02-03 Valero ............................... 19.62
2020-02-11 Chevron gas station .................. 15.57
2020-02-15 Car loan interest .................... 63.19
2020-02-17 Jiffy lube - oil change .............. 49.22
2020-02-19 Valero ............................... 19.26
2020-02-27 Valero ............................... 16.42
Total ................................ 183.28
Groceries (4)
2020-02-02 Kroger ............................... 203.60
2020-02-10 Kroger ............................... 185.40
2020-02-18 Kroger ............................... 174.87
2020-02-26 Kroger ............................... 133.56
Total ................................ 697.43
Misc (6,4)
2020-02-11 video game ........................... 65.29
2020-02-15 Netflix .............................. 9.73
2020-02-15 Spotify .............................. 10.81
Food in restaurant
2020-02-03 Drinks with coworkers ................ 15.13
2020-02-17 Drinks with coworkers ................ 15.07
Total ................................ 30.20
Total ................................ 165.98
Total ................................. 2511.88
Income (6,0)
City Zoo
2020-02-14 City Zoo - payroll ................... -1731.32
2020-02-28 City Zoo - payroll ................... -1731.32
Total ................................ -3462.64
Miscellaneous (4)
2020-02-02 Home Depot - supplies for ERICDECK ... 598.83
2020-02-03 Home Depot - saw blade for ERICDECK... 49.29
2020-02-03 Home Depot - supplies for ERICDECK ... 399.74
2020-02-06 ERICDECK - paid by check ............. -2082.84
Total ................................ -1034.98
Total .................................. -4497.62
Total ................................... -1985.74
Add-ons that make it “life management” software
Every time I fill up my car, I record the mileage and the gallons of gas. Every time I change the oil, I record the mileage of the next change. My main report script looks for my car's current mileage (based on the last gas record) and the mileage of the next oil change (from the last oil change record) and prints out how many miles I have left before I need to change my oil.
date,description,value,from,to 2026-01-07,08Civic - Gas - 8.209 - 320.5 - 145078 ,30.23,amex,trans 2026-01-07,08Civic - Oil - Jiffylube - next change 148100,65.43,amex,trans
When I record my utility bills, I record the amount of the thing I purchased.
date,description,value,from,to 2026-01-20,Water bill - 4500 gal ,29.87,amex,housing 2026-01-20,Electric bill - 2836 kwh,327.98,amex,housing 2026-01-20,Gas bill - 13 CCF,45.67,amex,housing
These records allow me to judge if something is wrong with my usage or if prices are rising. In the southern US where I live, AC is 50% of the electric bill. If something malfunctions in your air conditioner, it can cause anything from a mild increase to a doubling of power usage. By the same token, recording water usage clearly shows whether prices are increasing or I have a leak.