aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <chaffinach+git@protonmail.ch>2022-04-28 09:32:26 +0100
committerMatthew Lemon <chaffinach+git@protonmail.ch>2022-04-28 09:32:26 +0100
commitef297ce2c65aead25b755f9cc3ed4b8705733299 (patch)
tree93bb720da83b0922659b18457dc311966799029c
parent0ad0bf99f78a055b971806d2f87c7db22fa5d88e (diff)
new script to create an expense category file for ledger
Diffstat (limited to '')
-rw-r--r--ledgerscripts/get_categories.pl18
1 files changed, 18 insertions, 0 deletions
diff --git a/ledgerscripts/get_categories.pl b/ledgerscripts/get_categories.pl
new file mode 100644
index 0000000..fc4fa96
--- /dev/null
+++ b/ledgerscripts/get_categories.pl
@@ -0,0 +1,18 @@
+#!/usr/bin/env perl
+#
+# This groups a transaction description to an expense category
+# and prints to STDOUT to piping and or filtering elsewhere.
+#
+# The objective is for the output file to be used as a reference
+# for another script which applies expense categories to new
+# unprocessed budget files automatically.
+
+use strict;
+use warnings;
+
+local $/ = ""; # switch to paragraph mode (allow use of /m modifier below)
+
+while (<>) {
+ if (/\d{4}.*\* (.*)$/m) { print $1 . "@" };
+ if (/Expenses:(.*)£/) { print $1 . "\n" };
+}