Insert code field in existing journal

Hi. Is there a way to take an existing journal file and insert the same code field in every transaction?

I brought in 8 CSV files into 8 separate journal files, and manually edited each journal to fix up a few ‘unknown’ accounts, etc. before deciding I want the code field to denote the source bank account.

I changed my CSV rules files to include the code fields in the future, but really don’t want to re-run the CSV files and have to re-do all the manual adjustments.

I saw a reddit post suggesting using awk to adjust the text files, but thought I should check to see if there was an hledger command to do this. (I read the docs on ‘hledger print’ and came up empty)

No, there's no hledger command to alter the code field. Since you don't want to redo your manual fixups to the csv conversion, I think awk/sed or a search/replace or macro command in your text editor is the way to go.

1 Like

Thanks Simon. I wrote an awk script (my first!) and made the changes. PS - I’m a massive hledger fan – been using it for 5 years and finally decided to streamline my workflows. :slight_smile:

1 Like

Excellent!