aboutsummaryrefslogtreecommitdiffstats
path: root/process_hsbc_transactions.sh
diff options
context:
space:
mode:
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