apauley / fnb-csv-demoronizer

Demoronize CSV Statements from FNB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FNB CSV Statement Demoronizer

The Problem

FNB can email statements in CSV format (in addition to the normal PDF), if you enable that feature.

This is a nice feature - I would like to import my statements into my personal finance tool of choice, without having to remember to go online and download it myself.

The problem is that the actual format of the e-mailed CSV statement is moronic. Which is strange, since the CSV format you get when manually going into your internet banking and downloading your transaction history yourself is mostly sensible.

Below is an example of what one can expect in the e-mailed CSV statement:

2,account_number,'MR JOHN D DEER','FNB TJEKREKENING'
3
3,,'Staat'
3,'Staatnommer','Vanaf Datum','Tot Datum','Openingsaldo','Afsluitingsaldo','BTW Gehef'
3,55,'28 Desember 2017','28 Januarie 2018',0.01,0.01,-0.01
4
4,,'Opsomming'
4,,,'Rente op Debietsaldo',.00%
4,'Staat Datum','Beskrywing','Nommer','Sub Totaal','Totaal'
4,'28 Januarie 2018','Openingsaldo',,,0.01
4,'28 Januarie 2018','Afsluitingsaldo',,0.01
4,'28 Januarie 2018','Oortrekke Limiet',,0.01
5
5,,'Transaksies'
5,'Nommer','Datum','Beskrywing1','Beskrywing2','Beskrywing3','Bedrag','Saldo','Opgeloopte Koste'
5,1,'29 Des',"Inw Ontvangs","Company, Inc",,0.01,0.01,
5,2,'01 Jan',"Gereeld Bet Na","ABC","XYZ",-0.01,0.01,
6,'END'

The biggest problem is that the dates in the transaction lines is not in any acceptable standard format such as ISO 8601. It doesn’t even include the year. And transactions in the same statement may span over more than one year.

The Solution

This script will extract the transactions from a CSV statement like the one above, and fix the dates in the process.

It should look something like this:

"5","'Nommer'","'Datum'","'Beskrywing1'","'Beskrywing2'","'Beskrywing3'","'Bedrag'","'Saldo'","'Opgeloopte Koste'"
"5","1","2017-12-29","Inw Ontvangs","Company, Inc","","0.01","0.01",""
"5","2","2018-01-01","Gereeld Bet Na","ABC","XYZ","-0.01","0.01",""

Usage

Just run the script and look at the help text:

./fnb-csv-demoronizer
USAGE: fnb-csv-demoronizer statement.csv [output.csv]

You can also run some internal tests:

./fnb-csv-demoronizer test -v

About

Demoronize CSV Statements from FNB


Languages

Language:Python 100.0%