aboutsummaryrefslogtreecommitdiffstats
path: root/process_hsbc_transactions.sh
diff options
context:
space:
mode:
authorMatthew Lemon <chaffinach+git@protonmail.ch>2022-01-07 11:04:53 +0000
committerMatthew Lemon <chaffinach+git@protonmail.ch>2022-01-07 11:04:53 +0000
commit80fd0f8fe145e9c52e3b4a94a2fa2f7b071c4796 (patch)
tree4eed73bc6a14ba8f205b71e94cf4a24042ced366 /process_hsbc_transactions.sh
parent003008c0cf6a4eacfcd69623d4d9852c4202a209 (diff)
script now cleans itself up a bit better
Diffstat (limited to '')
-rwxr-xr-xprocess_hsbc_transactions.sh15
1 files changed, 13 insertions, 2 deletions
diff --git a/process_hsbc_transactions.sh b/process_hsbc_transactions.sh
index 5ab0caf..fc9afb6 100755
--- a/process_hsbc_transactions.sh
+++ b/process_hsbc_transactions.sh
@@ -4,7 +4,11 @@ tf="TransactionHistory.csv"
trap 'rm -f "$tmpfile"' EXIT
tmpfile=$(mktemp) || exit 1
-echo "Our tempfile is $tmpfile"
+echo "Our main tempfile is $tmpfile"
+
+trap 'rm -f "$ledgertmp"' EXIT
+ledgertmp=$(mktemp) || exit
+echo "Our ledger formatted tempfile is $ledgertmp"
if [[ -a "~/Downloads/$tf" ]]; then tpath="~/Downloads/$tf"
elif [[ -a "$(pwd)/$tf" ]]; then tpath="$(pwd)/$tf"
@@ -21,10 +25,17 @@ echo -e "Transaction File: $tpath"
sed -i $'1s/^\uFEFF//' $tpath
while read line; do
+ line=${line/"-"/"£"}
echo -e "$line\n$(cat $tmpfile)" > $tmpfile
done < $tpath
+# how to append to a text file in bash
echo -e "Date,Description,Amount\n$(cat $tmpfile)" > $tmpfile
+
echo "Sorted transaction file: $tmpfile"
-$(ledger convert --input-date-format "%d/%m/%Y" $tmpfile > toss)
+$(ledger convert --input-date-format "%d/%m/%Y" $tmpfile > $ledgertmp)
+
+# Remove the erroneous Equity lines
+sed -i '/Equity:Unknown/d' $ledgertmp
+cat $ledgertmp