Python Solves Group Financials

Python Solves Group Living Finances

Are you looking for a way to simplify your flat’s finances? Well I have the right script (i.e. small program) for you! To run this script you will need the following:

  • Programming Experience Required: None
  • Python 3 or higher installed on your machine
  • Access to your shared bank account via internet banking (don’t worry, this script won’t need your credentials, just the transaction data to sort out the mishaps!)

I’m currently studying towards a bachelor science in Computer Science and Psychology. Throughout my studies I have chosen to experience flatting i.e. living with a bunch of friends. This has always been a great experience, however there’s one topic that tends to be avoided to keep people happy:  money.

If you’ve had similar experiences in the past or are experiencing this right now then please keep reading, as this script can help you logically solve them. I would like to point out that I built this script for my own programming pleasure and it is very likely that you can get the same result a lot faster by using a tool you’re comfortable with.

This script is open-source and I promise it doesn’t send your valuable information /or finances across the internet. If you don’t trust it, ask someone with programming experience to take a look at it or don’t use. Better to be safe 🙂

This script requires a few things:

  • The .csv file which can be downloaded from your bank’s website
  • The Python script
  • Very basic command line ability (I will explain everything)
  • Python 3 to be installed

Regarding the command line, I’ll be attacking this from a Windows perspective, as I’m assuming anyone who has a distribution of Linux is well versed with the terminal. Just be careful with the direction of the slashes…

Download the .csv file and the .py script to a place you where you can find it. e.g. C:\Users\USERNAME\Documents\Python

It will also be helpful to rename the file to something smaller and that contains no spaces.
e.g. bankaccount_2014.csv

Now, using the file explorer, locate to where you’ve saved the .csv file and the .py file. It should look like this:explorer_cli_python_csv

Now we need to open up the Windows command line. Don’t worry, I like walk you through this and we will be using minimal commands. As a side note the command line can be very useful, so if this example feels fun, head over to your favourite search engine and do some research!

Now, hold down [SHIFT] on your keyboard, right click the folder and select ‘Open Command Window Here’

A window will open up with a very limited visual interface, but it’s very powerful once you know how to use it!

C:\Users\YourUsername\YourFolderPath is where you have opened the command line. To check that everything we want is there. Type dir /b and then press enter. What you should now see printed to the command line is all the files in the current directory, the /b is an argument given to display only the minimal presentation of files. If you’re interested try “dir” own it’s own and observe the difference.

Quickly we’ll check that you have Python 3 installed and accessible. Type python and press enter. If it displays Python 3.x.x, great! Press [CTRL] + [z] to end the Python interpreter. *If it displays “python is not recognized as a internal or external command, …” then you need to go install Python and add it to your path (The GUI installer has a drop-down entry for this)

Almost there! Below I will use XXX as a placeholder for the name of your .csv file. If that confuses you, rename the .csv file to XXX.csv (however, this might seem dodgy when you look back through your documents…)

To run the script on your data, type: python XXX.csv 

If you’re rushing to look at the result, type: output.txt and press enter! This should open up the output of the script in your standard text editor (probably Notepad or Word, for most). Great, now go analyze those mischievous transactions and the fairness of everyone’s contributions. Stop here if you’ve had enough of the command line and just want to get to the number crunching!

Yay, you’ve made it. If you’re interested in attempting to understand the code, have a read over at GitHub,I originally made this script just for myself then I had friends complaining about similar problems, so I adapted it and sent it off to them. The “>” writes all the print calls to an output file. This should have been placed into the script, however I prefer to send the output through many programs in my spare-time. In the GNU/Linux terminal, this is referred to as ‘piping’ which uses the | key

I’ve now changed the script, so that it writes a file on it’s own.

It has been tested with Westpac and KiwiBank .csv files. I’m sure other banks format their data differently, as I couldn’t find a universal standard anywhere. Comment if the script doesn’t work on your particular .csv file and I’ll do my best to adapt it to your situation! You won’t need to give the .csv file, just one row (change the people’s names and figures at your will, it’s just the columns that are important)

Future Plans:

  • Optimize the code, so it runs more efficiently. E.g. use less nested for-loops, create a list for original name, upper and lower at the beginning instead of on the fly (i.e. pre-processing)
  • Add a Java GUI on-top of the Python code, so that the user can drag and drop their .csv file into the application without having to open up the command line
  • Format the output nicely (i.e. line-by-line) and possibly convert back to readable .csv
  • Create a ‘smarter’ version, that dynamically locates the name/date/input/total/description fields and can run without the user having to input the people’s names (dictionaries will be key here)

Hope it helps! Leave a comment below if you need assistance or would like to show your appreciation.

Twitch Follower Alert i.e. win prizes from giveaways!


While watching streamers on I noticed an abundance of channels doing “giveaways at n followers”. Wouldn’t it be great to win some prizes without watching 30 channels simultaneously I thought to myself.

  • Problem 1: I don’t have 30 monitors
  • Problem 2: I generally only tune in for tournaments and don’t have time to view so much media

Solution: Python + Twitch API Here is my solution and my face when it works:





I’m currently in my final semester of University and with employment around the corner, I thought I would tidy up my cv.


I used LaTeX to produce it, let me know how it looks/reads in the comment section!

Quick Update


Hello internet,

I’ve been rather truant in my posting recently, mostly due to workload of university and work. Anyway, I’ve got mid-term tests coming up and thought you (the reader) maybe interested in my preparation.

By far, the most challenging paper I’m taking is an Artificial Intelligence course. It appears the mid-term for this paper will revolve around solving demanding programming problems using Clojure. To add to the excitement, we’re limited to using Vim, Emacs or Nano (i.e. only the tools available on the lab machines).

While the latter doesn’t phase me, I’m predicting an onslaught of difficult problems. To prepare for this, I’m frantically working my way through: Structure and Interpretation of Computer Programs, because it offers many exercises similar to what our professor has asked before.

In the future I plan to release my answers to the exercises (in Clojure), but if anyone is looking, I’ve found someone who has done just that.

After the break, one of my classes involves building a game that can be displayed on a LED grid, that’s multi-player via infra-red. So I’m really excited to play around with some hardware and getting those lights flashing as soon as possible!

That’s all for now,

New Lifting Routine (Starting Strength week 5 1/2)


I’m now 5 and a half weeks through Starting Strength. I’ve stalled on my lifts a couple of times and have gotten a wee bit bored of the routine, so I’ve decided to take a break (meaning I’ll come back in approximately 4 weeks) and try something new.

Starting Strength is a strength routine and as much as I love lifting heavy things off the ground / into the air, I’m looking to mix things up. After a lot of analysis paralysis I decided on PHAT, which is a strength/hypertrophy routine that is split over 5 days. Unfortunately I don’t have enough time to do both cardio and the full 5 days of lifting, so I’ve condensed it down to 4 days. To be fair, I’m now no-longer following the ‘official program’ but more of an adaption for my needs, not Layne’s (the god of the program).

Before I continue, I’ll show a spreadsheet of my last half week of SS:


I was most happy with the standing overhead-press of 50kg x 5, those readers who lift weights will know that plates usually come in 1.25, 2.5, 5, 10, 15, 20, 25 (if you’re lucky), and it is always such an achievement loading up a new plate size and removing the need to play Tower of Hanoi on the barbell.

Below is the condensed routine:


This has a lot more volume than I am used to, so I’ll definitely be easing into the program. Before anyone hounds me for the lack of pull-ups/chin-ups, I agree, but I have a ‘doorway pull-up’ bar at home and hence chose not to clutter my pretty spreadsheet.

I have stripped exercises that required equipment that my gym didn’t have, when I say stripped, I really mean replaced with free weight alternatives.

This week I’ve done both strength/heavy days, so I’m really looking forward to the hypertrophy equivalents to come.

I encourage anyone who spots glaring issues with the program to please comment.


JFLAP, XML and Python (COSC261 fix)


Last semester at University, I took a course based around ‘Formal Languages and Compilers’ aka COSC261. We had weekly quizzes to complete, which was great, but there was one task that always felt a lot more tedious than it needed to be: translating JFLAP diagrams to a transition table in to list of lists e.g. [ [ ], [ ] ] format, as required by the University’s quiz server.

I felt a couple stabs to the grade-book as I hastily submitted DFAs that worked perfectly on my local machine, but were rejected via the quiz server. The rejection was solely caused by mishandling of the data entry. As any geek would, I raged at the thought of mindless data entry and studied the implementation of JFLAP. It turns out that JFLAP saves as a .jff file, which does sound mysterious, until I inspected it in vim. Below is a screenshot of the inspection and the implementation.


Sure enough, it was a neat XML representation. Have a look for yourself, the developers put a lot of effort into the formatting (thanks a lot, team).

$ vim yourJFLAPfile.jff

Once in vim, you’ll need to enter :q! to exit, yes include the colon. This quits without saving, as you probably don’t want to modify the file directly (i.e. likelihood of adding errors).

Recently I had been working on processing data-feeds, which the majority of which were RSS/XML based, so this was a breath of familiar air indeed. My implementation is merely a proof of concept and definitely encourage anyone with enough time to improve upon it! The output is currently a tuple (FROM, [TO, SYMBOL]). As a trivial exercise you’re welcome to convert this to a list of lists, so that the quiz server does indeed accept it.

I’ll leave challenge of interpreting the parsing as homework. The script and all directions are on GitHub:

Some of the issues I ran into were:

  • Parsing Epsilon
  • Withholding the frustrated knowledge of how many marks could have been saved

Future Aims:

  • Implement for NFA, currently it works great with DFA (I’ve already added the ability to process Epsilon and the entries for each node are not statically typed)
  • Build an implementation of the script that links to our schools variant of Moodle, so that students can upload the JFLAP files (be sure to watch out for that nasty XML).

Starting Strength, Week 4


week4_Starting_StrengthJust a small update today. Week 4 of Starting Strength is complete. Squats, deadlifts and overhead press are continuing to increase, which is awesome. Having done OHP twice this week, I’m really excited about increasing my bench soon, since I’m yet to achieve that final rep on the last set of 75×5 legitimately without a spotter’s assistance. Hopefully this week will be the week!

Just 8 more weeks to go. I can see bodyweight exercises such as pull ups and chin ups becoming increasingly difficult as I had mass to my frame (especially legs from squats 3x a week).

That’s all for now,


Starting Strength, Week 3


I have successfully completed week 3! Quite happy with that indeed. I’m writing this post part way into week 4, unfortunately the 75kg bench press was too heavy for me today and I couldn’t complete the last set (only got 3 reps, before getting spotter’s assistance). I rested well before the last set but just couldn’t power through it. Because of this, I’ve decided to cut the assistance exercises until I get back on that linear progression train (I was greedy putting them in, anyway).

On a positive note, all other lifts have been increasing. And I can now do 3 unassisted chin-ups, which isn’t bad for an overweight guy 96kg at 5’9. My battle plan is continue this strength training until I’ve reached my goals (60kg Overhead-Press, 100 kg Bench, 120kg Squat and 140kg Deadlift).

Starting Strength, Week 3