Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Any change you open sourced those parsers? I also switched from GnuCash to ledger-cli a long time ago, so I'm interested to see your solution.


I did not, mostly because the parsers are custom to how I want things displayed. Here is a simplified example for Chase, though:

  BEGIN{
      FS = ",";
  }
  {
      if(FNR > 1){
          date = gensub(/([0-9]{2})\/([0-9]{2})\/([0-9]{4})/, "\\3-\\1-\\2", 1, $1);
          print date, $3
          print "    liabilities:chase"
          if($5 != "Payment"){
              print "    expenses:" $4, "  $", $6 \* -1.0
          }else{
              ## This exists because I have an offset in the account
              ## I use to pay the card with. If the amount in my residual
              ## account != 0, I know there is something wrong
              print "    liabilities:chase:residual  $", -$6
          }
      }
  }
Suppose this script is called 'parse.awk', you would then run: awk -f parse.awk myfile.csv

I've been doing this for a couple years now and so far I haven't had file formats change on me. Most of the complexity I have experienced so far is when the regex to parse line-items into the appropriate ledger account is non-trivial. It started off as a way for me to learn awk and double entry bookkeeping and somehow turned into something useful.


> It started off as a way for me to learn ... and somehow turned into something useful

This is the way.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: