Import transactions from MoneyWiz to Ledger

I’ve been using MoneyWiz for years and I really love it for its good balance between usability and functionality. However, its synchronization replies on its commercial cloud service which makes me a little bit afraid. I have to regularly backup my transactions via its “Export to csv” option. On the other hand, Ledger has drawn my attention for a quite long time as I really appreciate its idea of plain text accounting. Also, double entry accounting sounds more universal and professional. Surely, its complexity makes it impractical for daily usage without an mature mobile app. Therefore, I decide to backup my transactions in ledger format and keep using MoneyWiz for daily usage.

We need to pre-process this file now and there are two things to notice. Firstly, all the fields are quoted by double quotes and there are commas in some fields which should not be regarded as separators. This is implemented by FPAT variable which is only supported by gawk version 4+. Secondly, transactions in this file are organized based on Accounts. Transactions of transfer/withdraw are different from normal income/expenses. One single transfer event corresponds to two records: one for transfer-from and one for transfer-to. Here is the awk file named by moneywiz.awk I use for pre-process and run as ./moneywiz.awk moneywiz.csv > moneywiz-tmp.csv.