summaryrefslogtreecommitdiffstats
path: root/content/blog/2015-02-27-a-quick-script-to-import-data-from-my-bank-to-gnucash
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2020-06-05 14:19:19 +0200
committerHarald Eilertsen <haraldei@anduin.net>2020-06-05 14:19:19 +0200
commit3a5504d031bbb2cc1eb80ca2929f2342cdeb727c (patch)
treec8b971cd00a5b9c81d6d2105048366aa7c88ccf4 /content/blog/2015-02-27-a-quick-script-to-import-data-from-my-bank-to-gnucash
parent1fa58a612e0d66b69cc0196831d0d375793aaac9 (diff)
downloadrabalderz-3a5504d031bbb2cc1eb80ca2929f2342cdeb727c.tar.gz
rabalderz-3a5504d031bbb2cc1eb80ca2929f2342cdeb727c.tar.bz2
rabalderz-3a5504d031bbb2cc1eb80ca2929f2342cdeb727c.zip
import more old posts.
Diffstat (limited to 'content/blog/2015-02-27-a-quick-script-to-import-data-from-my-bank-to-gnucash')
-rw-r--r--content/blog/2015-02-27-a-quick-script-to-import-data-from-my-bank-to-gnucash/index.md41
1 files changed, 41 insertions, 0 deletions
diff --git a/content/blog/2015-02-27-a-quick-script-to-import-data-from-my-bank-to-gnucash/index.md b/content/blog/2015-02-27-a-quick-script-to-import-data-from-my-bank-to-gnucash/index.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.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/