Last active
          February 3, 2021 08:21 
        
      - 
      
 - 
        
Save simonmichael/5153401 to your computer and use it in GitHub Desktop.  
    example hledger 0.20 csv reader rules for a two-amount-column csv file 
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    | Date | Details | Debit | Credit | Balance | |
|---|---|---|---|---|---|
| 07/12/2012 | LODGMENT 529898 | 10.0 | 131.21 | ||
| 07/12/2012 | PAYMENT | 5 | 126 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # hledger csv conversion rules for bank of ireland | |
| # sample of CSV being converted | |
| # Date,Details,Debit,Credit,Balance | |
| # 07/12/2012,LODGMENT 529898,,10.0,131.21 | |
| # 07/12/2012,PAYMENT,5,,126 | |
| # 1 2 3 4 5 | |
| # skip the header line | |
| skip-lines 1 | |
| # name the csv fields, and assign some of them as entry fields | |
| fields date, description, debit, credit, balance | |
| # date is in UK/Ireland format | |
| date-format %-d/%-m/%Y | |
| # set the currency | |
| default-currency EUR | |
| # set the base account for all txns | |
| account1 assets:bank:bank of ireland:checking | |
| # use the debit field, negated, as the amount | |
| amount -%3 | |
| # or if the debit field is empty use the credit field | |
| if ~ | |
| ^[^,]*,[^,]*,, | |
| amount %4 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | $ hledger -f .bofi-checking.csv print | |
| using conversion rules file .bofi-checking.csv.rules | |
| 2012/12/07 LODGMENT 529898 | |
| income:unknown EUR-10.0 | |
| assets:bank:bank of ireland:checking EUR10.0 | |
| 2012/12/07 PAYMENT | |
| expenses:unknown EUR5 | |
| assets:bank:bank of ireland:checking EUR-5 | |
| $ | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment