Extract multiple HLedger fields from a CSV column

Hi all :waving_hand:

When importing into hledger, using rules, is there a way to break up a column into fields?

e.g. I have a CSV column with "Outward Instant Transaction CODE1 CODE2 REMARK TO BANK - ACCOUNT". This column contains…

"{marker} {txn ref} {remark} TO {description}"

How do I parse out these fields

p.s: it's clear to me how to join columns to get a hledger field, I would like to do the reverse here.

p.p.s: the full CSV line reads something like

Outward Instant Transaction CODE1 CODE2 REMARK TO BANK - ACCOUNT, §, 12-Dec-2022, 12-Dec-2022, 300, "", ABC123

which I have translated to

%{field_to_extract_other_fields}, %{ignore_1}, %{date}, %{date2}, %{amount-out}, %{amount-in}, %{code}

Thanks!

You can't do it with hledger's CSV rules - you'd need to write your own little parser to pre-process and split the CSV into more columns.

1 Like