From a19d98ce7e590e6c7f82aa08f7e9791a72e2e8bc Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 7 Jun 2020 14:14:41 +0200 Subject: Split english and norwegian posts. This turned out a bit different than I initially though. The english and norwegian sections will essentially be separate. Afaict there's no direct way to make a "combined view" listing both english and norwegian posts. However, I think that's fine. Let's roll with this for now. --- .../index.en.md | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 content/blog/2015-02-27-a-quick-script-to-import-data-from-my-bank-to-gnucash/index.en.md (limited to 'content/blog/2015-02-27-a-quick-script-to-import-data-from-my-bank-to-gnucash/index.en.md') diff --git a/content/blog/2015-02-27-a-quick-script-to-import-data-from-my-bank-to-gnucash/index.en.md b/content/blog/2015-02-27-a-quick-script-to-import-data-from-my-bank-to-gnucash/index.en.md new file mode 100644 index 0000000..10ddd40 --- /dev/null +++ b/content/blog/2015-02-27-a-quick-script-to-import-data-from-my-bank-to-gnucash/index.en.md @@ -0,0 +1,41 @@ ++++ +title = "A quick script to import data from my bank to GnuCash" +lang = "en" + +[taxonomies] +tags = ["software", "programming", "scripts"] + +[extra] +author = "harald" ++++ + +Here's a quick awk script I did to convert the bank statements from my bank to a +format recognizable by [GnuCash]: + +```awk +# A simple filter to mould the csv from nordea into +# something that can be swallowed by gnucash. + +BEGIN { + FS = ";"; + RS = "\n"; + OFS = ";"; + ORS = "\n"; + + # Regex for matching a date + DATE = /^[0-9]{4}\.[0-9]{2}\.[0-9]{2}$/; +} + +# Only lines starting with a date should be printed +$2 ~ DATE { + # Strip negative sign from withdraw column + withdraw = gensub(/\-/, "", "g", $8); + print $2,$4,$6,withdraw,$10; +} +``` + +It could probably be shorter. I could drop setting the RS/ORS, but I like to be explicit. In addition to fixing the polarity of the withdrawals column it strips away all the lines that don't contain any transactions. I don't need them, and this saves me from having to do it manually in GnuCash. + +Not anything revolutionary, but thought I'd share it anyways. + +[GnuCash]: http://www.gnucash.org/ -- cgit v1.2.3