388 lines
		
	
	
		
			7.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			388 lines
		
	
	
		
			7.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| # 1. read CSV to hledger journal format
 | |
| <
 | |
| 10/2009/09,Flubber Co,50
 | |
| RULES
 | |
| fields date, description, amount
 | |
| date-format %d/%Y/%m
 | |
| currency $
 | |
| account1 assets:myacct
 | |
| 
 | |
| $  ./hledger-csv
 | |
| 2009/09/10 Flubber Co
 | |
|     assets:myacct               $50
 | |
|     expense:unknown
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 2. reading CSV with in-field and out-field
 | |
| <
 | |
| 10/2009/09,Flubber Co🎅,50,
 | |
| 11/2009/09,Flubber Co🎅,,50
 | |
| RULES
 | |
| account1 Assets:MyAccount
 | |
| date %1
 | |
| date-format %d/%Y/%m
 | |
| description %2
 | |
| amount-in %3
 | |
| amount-out %4
 | |
| currency $
 | |
| 
 | |
| $  ./hledger-csv
 | |
| 2009/09/10 Flubber Co🎅
 | |
|     Assets:MyAccount             $50
 | |
|     expense:unknown
 | |
| 
 | |
| 2009/09/11 Flubber Co🎅
 | |
|     Assets:MyAccount            $-50
 | |
|     income:unknown
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 3. handle conditions assigning multiple fields
 | |
| <
 | |
| 10/2009/09,Flubber Co,50
 | |
| 
 | |
| RULES
 | |
| fields date, description, amount
 | |
| date-format %d/%Y/%m
 | |
| currency $
 | |
| account1 assets:myacct
 | |
| if Flubber
 | |
|   account2 acct
 | |
|   comment cmt
 | |
| $  ./hledger-csv
 | |
| 2009/09/10 Flubber Co  ; cmt
 | |
|     assets:myacct             $50
 | |
|     acct
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 4. read CSV with balance field
 | |
| <
 | |
| 10/2009/09,Flubber Co,50,123
 | |
| 
 | |
| RULES
 | |
| fields date, description, amount, balance
 | |
| date-format %d/%Y/%m
 | |
| currency $
 | |
| account1 assets:myacct
 | |
| 
 | |
| $  ./hledger-csv
 | |
| 2009/09/10 Flubber Co
 | |
|     assets:myacct               $50 = $123
 | |
|     expense:unknown
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 5. read CSV with empty balance field
 | |
| <
 | |
| 10/2009/09,Flubber Co,50,123
 | |
| 11/2009/09,Blubber Co,60,
 | |
| 
 | |
| RULES
 | |
| fields date, description, amount, balance
 | |
| date-format %d/%Y/%m
 | |
| currency $
 | |
| account1 assets:myacct
 | |
| 
 | |
| $  ./hledger-csv
 | |
| 2009/09/10 Flubber Co
 | |
|     assets:myacct               $50 = $123
 | |
|     expense:unknown
 | |
| 
 | |
| 2009/09/11 Blubber Co
 | |
|     assets:myacct               $60
 | |
|     expense:unknown
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 6. read CSV with only whitespace in balance field
 | |
| <
 | |
| 10/2009/09,Flubber Co,50,123
 | |
| 11/2009/09,Blubber Co,60,   
 | |
| 
 | |
| RULES
 | |
| fields date, description, amount, balance
 | |
| date-format %d/%Y/%m
 | |
| currency $
 | |
| account1 assets:myacct
 | |
| 
 | |
| $  ./hledger-csv
 | |
| 2009/09/10 Flubber Co
 | |
|     assets:myacct               $50 = $123
 | |
|     expense:unknown
 | |
| 
 | |
| 2009/09/11 Blubber Co
 | |
|     assets:myacct               $60
 | |
|     expense:unknown
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 7. read CSV with rule double-negating column
 | |
| <
 | |
| date,payee,amount
 | |
| 2009/10/9,Flubber Co,50
 | |
| 2009/11/09,Merchant Credit,-60
 | |
| 
 | |
| RULES
 | |
| skip 1
 | |
| 
 | |
| currency $
 | |
| 
 | |
| fields date, payee, payment
 | |
| 
 | |
| amount -%payment
 | |
| account1 liabilities:bank
 | |
| account2 expense:other
 | |
| $  ./hledger-csv
 | |
| 2009/10/09
 | |
|     liabilities:bank            $-50
 | |
|     expense:other
 | |
| 
 | |
| 2009/11/09
 | |
|     liabilities:bank             $60
 | |
|     expense:other
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 8. reading with custom separator: SSV (semicolon-separated)
 | |
| <
 | |
| 10/2009/09;Flubber Co🎅;50;
 | |
| 11/2009/09;Flubber Co🎅;;50
 | |
| RULES
 | |
| account1 Assets:MyAccount
 | |
| date %1
 | |
| date-format %d/%Y/%m
 | |
| description %2
 | |
| amount-in %3
 | |
| amount-out %4
 | |
| currency $
 | |
| 
 | |
| $  ./hledger-csv --separator ';'
 | |
| 2009/09/10 Flubber Co🎅
 | |
|     Assets:MyAccount             $50
 | |
|     expense:unknown
 | |
| 
 | |
| 2009/09/11 Flubber Co🎅
 | |
|     Assets:MyAccount            $-50
 | |
|     income:unknown
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 9. read CSV with balance2 field
 | |
| <
 | |
| 10/2009/09,Flubber Co,50,123
 | |
| 
 | |
| RULES
 | |
| fields date, description, amount, balance2
 | |
| date-format %d/%Y/%m
 | |
| currency $
 | |
| account1 assets:myacct
 | |
| 
 | |
| $  ./hledger-csv
 | |
| 2009/09/10 Flubber Co
 | |
|     assets:myacct               $50
 | |
|     expense:unknown     = $123
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 10. read CSV with balance1 and balance2 fields
 | |
| <
 | |
| 10/2009/09,Flubber Co,50,321,123
 | |
| 
 | |
| RULES
 | |
| fields date, description, amount, balance1, balance2
 | |
| date-format %d/%Y/%m
 | |
| currency $
 | |
| account1 assets:myacct
 | |
| 
 | |
| $  ./hledger-csv
 | |
| 2009/09/10 Flubber Co
 | |
|     assets:myacct               $50 = $321
 | |
|     expense:unknown     = $123
 | |
| 
 | |
| >=0
 | |
| 
 | |
| 
 | |
| # 11. More than two postings
 | |
| <
 | |
| 10/2009/09,Flubber Co,50,321,123,0.234,VAT
 | |
| 
 | |
| RULES
 | |
| fields date, description, amount, balance1, balance2, amount3,comment3
 | |
| date-format %d/%Y/%m
 | |
| currency $
 | |
| account1 assets:myacct
 | |
| account3   expenses:tax
 | |
| 
 | |
| $  ./hledger-csv
 | |
| 2009/09/10 Flubber Co
 | |
|     assets:myacct             $50 = $321
 | |
|     unknown           = $123
 | |
|     expenses:tax           $0.234  ; VAT
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 12. More than two postings and different currencies
 | |
| <
 | |
| 10/2009/09,Flubber Co,50,321,123,£,0.234,VAT
 | |
| 
 | |
| RULES
 | |
| fields date, description, amount, balance1, balance2, currency3, amount3,comment3
 | |
| date-format %d/%Y/%m
 | |
| currency $
 | |
| account1 assets:myacct
 | |
| account3   expenses:tax
 | |
| 
 | |
| $  ./hledger-csv
 | |
| 2009/09/10 Flubber Co
 | |
|     assets:myacct             $50 = $321
 | |
|     unknown           = $123
 | |
|     expenses:tax           £0.234  ; VAT
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 13. reading CSV with in-field and out-field, where one could be zero
 | |
| <
 | |
| 10/2009/09,Flubber Co🎅,50,0
 | |
| 11/2009/09,Flubber Co🎅,0.00,50
 | |
| RULES
 | |
| account1 Assets:MyAccount
 | |
| date %1
 | |
| date-format %d/%Y/%m
 | |
| description %2
 | |
| amount-in %3
 | |
| amount-out %4
 | |
| currency $
 | |
| 
 | |
| $  ./hledger-csv
 | |
| 2009/09/10 Flubber Co🎅
 | |
|     Assets:MyAccount             $50
 | |
|     expense:unknown
 | |
| 
 | |
| 2009/09/11 Flubber Co🎅
 | |
|     Assets:MyAccount            $-50
 | |
|     income:unknown
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 14. multiline descriptions
 | |
| <
 | |
| 10/2009/09,"Flubber Co
 | |
| 
 | |
| 
 | |
| 
 | |
| Co
 | |
| Co
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| ",50
 | |
| 
 | |
| RULES
 | |
| fields date, description, amount
 | |
| date-format %d/%Y/%m
 | |
| currency $
 | |
| account1 assets:myacct
 | |
| $  ./hledger-csv
 | |
| 2009/09/10 Flubber Co Co Co
 | |
|     assets:myacct               $50
 | |
|     expense:unknown
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 15. recursive interpolation
 | |
| <
 | |
| myacct,10/2009/09,Flubber Co,50,
 | |
| 
 | |
| RULES
 | |
| 
 | |
| fields account1, date, description, amount-in, amount-out
 | |
| date-format %d/%Y/%m
 | |
| currency $
 | |
| if Flubber
 | |
|    account1  assets:%account1
 | |
|    amount-in  (%amount-in)
 | |
| $  ./hledger-csv
 | |
| 2009/09/10 Flubber Co
 | |
|     assets:myacct             $-50
 | |
|     income:unknown
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # 16. Real life-ish paypal parsing example
 | |
| <
 | |
| "12/22/2018","06:22:50","PST","Someone","Subscription Payment","Completed","USD","10.00","-0.59","9.41","someone@some.where","simon@joyful.com","123456789","Joyful Systems","","9KCXZZZZZXXAX","","57.60",""
 | |
| 
 | |
| RULES
 | |
| fields date, time, timezone, description, type, status_, currency, grossamount, feeamount, netamount, fromemail, toemail, code, itemtitle, itemid, referencetxnid, receiptid, balance, note
 | |
| account1 sm:assets:online:paypal
 | |
| amount1 %netamount
 | |
| account2 sm:expenses:unknown
 | |
| account3 JS:expenses:banking:paypal
 | |
| amount3 %feeamount
 | |
| balance %18
 | |
| code %13
 | |
| currency $
 | |
| date %1
 | |
| date-format %m/%d/%Y
 | |
| description %description for %itemtitle 
 | |
| $  ./hledger-csv
 | |
| 2018/12/22 (123456789) Someone for Joyful Systems
 | |
|     sm:assets:online:paypal              $9.41 = $57.60
 | |
|     sm:expenses:unknown
 | |
|     JS:expenses:banking:paypal          $-0.59
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # . TODO: without --separator gives obscure error
 | |
| #   |
 | |
| # 1 | 10/2009/09;Flubber Co🎅;50;
 | |
| #   | ^^^^^^^^^^
 | |
| # well-formed but invalid date: 10/2009/9
 | |
| # <
 | |
| # 10/2009/09;Flubber Co🎅;50;
 | |
| # 11/2009/09;Flubber Co🎅;;50
 | |
| # RULES
 | |
| # account1 Assets:MyAccount
 | |
| # date %1
 | |
| # date-format %d/%Y/%m
 | |
| # description %2
 | |
| # amount-in %3
 | |
| # amount-out %4
 | |
| # currency $
 | |
| # $  ./hledger-csv
 | |
| # 2009/09/10 Flubber Co🎅
 | |
| #     Assets:MyAccount             $50
 | |
| #     income:unknown              $-50
 | |
| #
 | |
| # 2009/09/11 Flubber Co🎅
 | |
| #     Assets:MyAccount            $-50
 | |
| #     expenses:unknown             $50
 | |
| #
 | |
| # >=0
 | |
| 
 | |
| # . reading TSV (tab-separated)  TODO user error (CSV record ["10/2009/09\tFlubber Co\127877\t50\t"] has less than two fields)
 | |
| # <
 | |
| # 10/2009/09	Flubber Co🎅	50	
 | |
| # 11/2009/09	Flubber Co🎅		50
 | |
| # RULES
 | |
| # account1 Assets:MyAccount
 | |
| # date %1
 | |
| # date-format %d/%Y/%m
 | |
| # description %2
 | |
| # amount-in %3
 | |
| # amount-out %4
 | |
| # currency $
 | |
| # $  ./hledger-csv
 | |
| # 2009/09/10 Flubber Co🎅
 | |
| #     Assets:MyAccount             $50
 | |
| #     income:unknown              $-50
 | |
| #
 | |
| # 2009/09/11 Flubber Co🎅
 | |
| #     Assets:MyAccount            $-50
 | |
| #     expenses:unknown             $50
 | |
| #
 | |
| # >=0
 |