`xactmon` is a new tool I developed to parse transaction notifications from banks and automatically import them into my personal finance tracker. It is designed in a modular fashion, composed of three main components: * Receiver * Processor * Importer Components communicate with one another using an AMQP exchange. Hypothetically, there could be multipel implementations of the receiver and importer components. Right now, there is only a JMAP receiver, which fetches email messages (from Fastmail), and a Firefly III importer. The processor is a singleton, handling notifications from the receiver, parsing them into a normalized format, and passing them on to the importer. It uses a set of rules to decide how to parse the messages, and supports using either a regular expression with named capture groups or an Awk script to extract the relevant information.
23 lines
308 B
Awk
23 lines
308 B
Awk
/ending in/ {
|
|
gsub(/^ +/, "");
|
|
account=$0
|
|
}
|
|
|
|
/•/ {
|
|
if (date=="") {
|
|
gsub(/[^0-9-]+/, "");
|
|
date=$0
|
|
} else if (description == "") {
|
|
gsub(/.*• /, "")
|
|
description=$0
|
|
} else if (amount == "") {
|
|
gsub(/[^0-9.]+/, "");
|
|
amount=$0
|
|
}
|
|
}
|
|
|
|
END {
|
|
OFS="|"
|
|
print(account, date, amount, description)
|
|
}
|