2012-03-26 02:12:52 +04:00
|
|
|
# 1. read CSV to hledger journal format
|
2019-10-12 23:12:50 +03:00
|
|
|
<
|
|
|
|
10/2009/09,Flubber Co,50
|
|
|
|
RULES
|
|
|
|
fields date, description, amount
|
|
|
|
date-format %d/%Y/%m
|
|
|
|
currency $
|
|
|
|
account1 assets:myacct
|
|
|
|
|
|
|
|
$ ./hledger-csv
|
2010-12-21 20:57:06 +03:00
|
|
|
2009/09/10 Flubber Co
|
2019-10-12 23:58:11 +03:00
|
|
|
assets:myacct $50
|
|
|
|
income:unknown
|
2010-12-21 20:57:06 +03:00
|
|
|
|
2019-06-07 00:37:36 +03:00
|
|
|
>=0
|
2012-01-30 21:18:32 +04:00
|
|
|
|
2012-03-26 02:12:52 +04:00
|
|
|
# 2. reading CSV with in-field and out-field
|
2019-06-07 00:37:36 +03:00
|
|
|
<
|
2018-09-07 20:12:13 +03:00
|
|
|
10/2009/09,Flubber Co🎅,50,
|
|
|
|
11/2009/09,Flubber Co🎅,,50
|
2019-10-12 23:12:50 +03:00
|
|
|
RULES
|
|
|
|
account1 Assets:MyAccount
|
|
|
|
date %1
|
|
|
|
date-format %d/%Y/%m
|
|
|
|
description %2
|
|
|
|
amount-in %3
|
|
|
|
amount-out %4
|
|
|
|
currency $
|
|
|
|
|
|
|
|
$ ./hledger-csv
|
2018-09-07 20:12:13 +03:00
|
|
|
2009/09/10 Flubber Co🎅
|
2017-06-05 07:26:18 +03:00
|
|
|
Assets:MyAccount $50
|
2019-10-12 23:58:11 +03:00
|
|
|
income:unknown
|
2012-03-26 02:12:52 +04:00
|
|
|
|
2018-09-07 20:12:13 +03:00
|
|
|
2009/09/11 Flubber Co🎅
|
2017-06-05 07:26:18 +03:00
|
|
|
Assets:MyAccount $-50
|
2019-10-12 23:58:11 +03:00
|
|
|
expense:unknown
|
2012-03-26 02:12:52 +04:00
|
|
|
|
2019-06-07 00:37:36 +03:00
|
|
|
>=0
|
2018-09-07 20:12:13 +03:00
|
|
|
|
2017-06-13 19:54:16 +03:00
|
|
|
# 3. handle conditions assigning multiple fields
|
2019-10-12 23:12:50 +03:00
|
|
|
<
|
|
|
|
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
|
2019-06-12 16:01:17 +03:00
|
|
|
2009/09/10 Flubber Co ; cmt
|
2017-06-05 07:26:18 +03:00
|
|
|
assets:myacct $50
|
2019-10-12 02:00:19 +03:00
|
|
|
acct
|
2013-06-19 11:29:45 +04:00
|
|
|
|
2019-06-07 00:37:36 +03:00
|
|
|
>=0
|
2016-10-09 04:20:26 +03:00
|
|
|
|
2017-06-13 19:54:16 +03:00
|
|
|
# 4. read CSV with balance field
|
2019-10-12 23:12:50 +03:00
|
|
|
<
|
|
|
|
10/2009/09,Flubber Co,50,123
|
|
|
|
|
|
|
|
RULES
|
|
|
|
fields date, description, amount, balance
|
|
|
|
date-format %d/%Y/%m
|
|
|
|
currency $
|
|
|
|
account1 assets:myacct
|
|
|
|
|
|
|
|
$ ./hledger-csv
|
2017-04-15 00:52:03 +03:00
|
|
|
2009/09/10 Flubber Co
|
2019-10-12 23:58:11 +03:00
|
|
|
assets:myacct $50 = $123
|
|
|
|
income:unknown
|
2017-04-15 00:52:03 +03:00
|
|
|
|
2019-06-07 00:37:36 +03:00
|
|
|
>=0
|
2017-06-13 19:54:16 +03:00
|
|
|
|
2017-06-14 18:54:32 +03:00
|
|
|
# 5. read CSV with empty balance field
|
2019-10-12 23:12:50 +03:00
|
|
|
<
|
|
|
|
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
|
2017-04-18 19:07:30 +03:00
|
|
|
2009/09/10 Flubber Co
|
2019-10-12 23:58:11 +03:00
|
|
|
assets:myacct $50 = $123
|
|
|
|
income:unknown
|
2017-04-15 00:52:03 +03:00
|
|
|
|
2017-04-18 19:07:30 +03:00
|
|
|
2009/09/11 Blubber Co
|
2019-10-12 23:58:11 +03:00
|
|
|
assets:myacct $60
|
|
|
|
income:unknown
|
2017-04-18 19:07:30 +03:00
|
|
|
|
2019-06-07 00:37:36 +03:00
|
|
|
>=0
|
2017-06-13 19:54:16 +03:00
|
|
|
|
2017-06-14 18:54:32 +03:00
|
|
|
# 6. read CSV with only whitespace in balance field
|
2019-10-12 23:12:50 +03:00
|
|
|
<
|
|
|
|
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
|
2017-04-18 19:07:30 +03:00
|
|
|
2009/09/10 Flubber Co
|
2019-10-12 23:58:11 +03:00
|
|
|
assets:myacct $50 = $123
|
|
|
|
income:unknown
|
2017-04-18 19:07:30 +03:00
|
|
|
|
|
|
|
2009/09/11 Blubber Co
|
2019-10-12 23:58:11 +03:00
|
|
|
assets:myacct $60
|
|
|
|
income:unknown
|
2017-04-18 19:07:30 +03:00
|
|
|
|
2019-06-07 00:37:36 +03:00
|
|
|
>=0
|
2017-06-13 19:54:16 +03:00
|
|
|
|
|
|
|
# 7. read CSV with rule double-negating column
|
2019-10-12 23:12:50 +03:00
|
|
|
<
|
|
|
|
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
|
2017-05-14 03:34:33 +03:00
|
|
|
2009/10/09
|
2017-06-05 07:26:18 +03:00
|
|
|
liabilities:bank $-50
|
2019-10-12 02:00:19 +03:00
|
|
|
expense:other
|
2017-05-14 03:34:33 +03:00
|
|
|
|
|
|
|
2009/11/09
|
2017-06-05 07:26:18 +03:00
|
|
|
liabilities:bank $60
|
2019-10-12 02:00:19 +03:00
|
|
|
expense:other
|
2017-05-14 03:34:33 +03:00
|
|
|
|
2019-06-07 00:37:36 +03:00
|
|
|
>=0
|
2018-09-07 20:12:13 +03:00
|
|
|
|
2018-09-07 23:42:44 +03:00
|
|
|
# 8. reading with custom separator: SSV (semicolon-separated)
|
2019-06-07 00:37:36 +03:00
|
|
|
<
|
2018-09-07 20:12:13 +03:00
|
|
|
10/2009/09;Flubber Co🎅;50;
|
|
|
|
11/2009/09;Flubber Co🎅;;50
|
2019-10-12 23:12:50 +03:00
|
|
|
RULES
|
|
|
|
account1 Assets:MyAccount
|
|
|
|
date %1
|
|
|
|
date-format %d/%Y/%m
|
|
|
|
description %2
|
|
|
|
amount-in %3
|
|
|
|
amount-out %4
|
|
|
|
currency $
|
|
|
|
|
|
|
|
$ ./hledger-csv --separator ';'
|
2018-09-07 20:12:13 +03:00
|
|
|
2009/09/10 Flubber Co🎅
|
|
|
|
Assets:MyAccount $50
|
2019-10-12 23:58:11 +03:00
|
|
|
income:unknown
|
2018-09-07 20:12:13 +03:00
|
|
|
|
|
|
|
2009/09/11 Flubber Co🎅
|
|
|
|
Assets:MyAccount $-50
|
2019-10-12 23:58:11 +03:00
|
|
|
expense:unknown
|
2018-09-07 20:12:13 +03:00
|
|
|
|
2019-06-07 00:37:36 +03:00
|
|
|
>=0
|
2018-09-07 23:43:05 +03:00
|
|
|
|
2019-03-16 00:18:44 +03:00
|
|
|
# 9. read CSV with balance2 field
|
2019-10-12 23:12:50 +03:00
|
|
|
<
|
|
|
|
10/2009/09,Flubber Co,50,123
|
|
|
|
|
|
|
|
RULES
|
|
|
|
fields date, description, amount, balance2
|
|
|
|
date-format %d/%Y/%m
|
|
|
|
currency $
|
|
|
|
account1 assets:myacct
|
|
|
|
|
|
|
|
$ ./hledger-csv
|
2019-03-16 00:18:44 +03:00
|
|
|
2009/09/10 Flubber Co
|
2019-10-12 23:58:11 +03:00
|
|
|
assets:myacct $50
|
|
|
|
income:unknown = $123
|
2019-03-16 00:18:44 +03:00
|
|
|
|
2019-06-07 00:37:36 +03:00
|
|
|
>=0
|
2019-03-16 00:18:44 +03:00
|
|
|
|
|
|
|
# 10. read CSV with balance1 and balance2 fields
|
2019-10-12 23:12:50 +03:00
|
|
|
<
|
|
|
|
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
|
2019-03-16 00:18:44 +03:00
|
|
|
2009/09/10 Flubber Co
|
2019-10-12 23:58:11 +03:00
|
|
|
assets:myacct $50 = $321
|
|
|
|
income:unknown = $123
|
2019-03-16 00:18:44 +03:00
|
|
|
|
2019-06-07 00:37:36 +03:00
|
|
|
>=0
|
2019-03-16 00:18:44 +03:00
|
|
|
|
|
|
|
|
2019-10-12 23:12:50 +03:00
|
|
|
# 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
|
2019-10-12 01:56:40 +03:00
|
|
|
2009/09/10 Flubber Co
|
2019-10-12 11:30:25 +03:00
|
|
|
assets:myacct $50 = $321
|
|
|
|
unknown = $123
|
|
|
|
expenses:tax $0.234 ; VAT
|
2019-10-12 01:56:40 +03:00
|
|
|
|
|
|
|
>=0
|
|
|
|
|
2019-10-12 23:12:50 +03:00
|
|
|
# 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
|
2019-10-12 01:56:40 +03:00
|
|
|
2009/09/10 Flubber Co
|
2019-10-12 11:30:25 +03:00
|
|
|
assets:myacct $50 = $321
|
|
|
|
unknown = $123
|
|
|
|
expenses:tax £0.234 ; VAT
|
2019-10-12 01:56:40 +03:00
|
|
|
|
|
|
|
>=0
|
|
|
|
|
2019-10-12 02:06:16 +03:00
|
|
|
# 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
|
2019-10-12 23:12:50 +03:00
|
|
|
RULES
|
|
|
|
account1 Assets:MyAccount
|
|
|
|
date %1
|
|
|
|
date-format %d/%Y/%m
|
|
|
|
description %2
|
|
|
|
amount-in %3
|
|
|
|
amount-out %4
|
|
|
|
currency $
|
|
|
|
|
|
|
|
$ ./hledger-csv
|
2019-10-12 02:06:16 +03:00
|
|
|
2009/09/10 Flubber Co🎅
|
|
|
|
Assets:MyAccount $50
|
2019-10-12 23:58:11 +03:00
|
|
|
income:unknown
|
2019-10-12 02:06:16 +03:00
|
|
|
|
|
|
|
2009/09/11 Flubber Co🎅
|
|
|
|
Assets:MyAccount $-50
|
2019-10-12 23:58:11 +03:00
|
|
|
expense:unknown
|
2019-10-12 02:06:16 +03:00
|
|
|
|
|
|
|
>=0
|
2019-10-12 01:56:40 +03:00
|
|
|
|
2019-10-12 02:49:42 +03:00
|
|
|
# 14. multiline descriptions
|
2019-10-12 23:12:50 +03:00
|
|
|
<
|
|
|
|
10/2009/09,"Flubber Co
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Co
|
|
|
|
Co
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
",50
|
|
|
|
|
|
|
|
RULES
|
|
|
|
fields date, description, amount
|
|
|
|
date-format %d/%Y/%m
|
|
|
|
currency $
|
|
|
|
account1 assets:myacct
|
|
|
|
$ ./hledger-csv
|
2019-10-12 02:49:42 +03:00
|
|
|
2009/09/10 Flubber Co Co Co
|
2019-10-12 23:58:11 +03:00
|
|
|
assets:myacct $50
|
|
|
|
income:unknown
|
2019-10-12 02:49:42 +03:00
|
|
|
|
|
|
|
>=0
|
|
|
|
|
2019-10-12 02:55:25 +03:00
|
|
|
# 15. recursive interpolation
|
2019-10-12 23:12:50 +03:00
|
|
|
<
|
|
|
|
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
|
2019-10-12 02:55:25 +03:00
|
|
|
2009/09/10 Flubber Co
|
2019-10-12 23:58:11 +03:00
|
|
|
assets:myacct $-50
|
|
|
|
expense:unknown
|
2019-10-12 02:55:25 +03:00
|
|
|
|
|
|
|
>=0
|
|
|
|
|
2019-10-12 23:22:40 +03:00
|
|
|
# 16. Real life-ish paypal parsing example
|
2019-10-12 12:00:14 +03:00
|
|
|
<
|
2019-10-12 23:58:11 +03:00
|
|
|
"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","","9KCXINCOME:UNKNOWNZXXAX","","57.60",""
|
2019-10-12 12:00:14 +03:00
|
|
|
|
|
|
|
RULES
|
2019-10-12 23:22:40 +03:00
|
|
|
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
|
2019-10-12 12:00:14 +03:00
|
|
|
currency $
|
2019-10-12 23:22:40 +03:00
|
|
|
date %1
|
|
|
|
date-format %m/%d/%Y
|
|
|
|
description %description for %itemtitle
|
2019-10-12 12:00:14 +03:00
|
|
|
$ ./hledger-csv
|
2019-10-12 23:22:40 +03:00
|
|
|
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
|
2019-10-12 12:00:14 +03:00
|
|
|
|
|
|
|
>=0
|
|
|
|
|
2019-10-12 23:58:11 +03:00
|
|
|
# 18. Show that #415 is fixed
|
|
|
|
<
|
|
|
|
"2016/01/01","$1"
|
|
|
|
"2016/02/02","$1,000.00"
|
|
|
|
RULES
|
|
|
|
account1 unknown
|
|
|
|
amount %2
|
|
|
|
date %1
|
|
|
|
date-format %Y/%m/%d
|
|
|
|
$ ./hledger-csv | hledger balance -f - --no-total
|
|
|
|
$-1,001.00 income:unknown
|
|
|
|
$1,001.00 unknown
|
|
|
|
>=0
|
|
|
|
|
2019-06-07 00:37:36 +03:00
|
|
|
# . TODO: without --separator gives obscure error
|
2018-09-07 23:43:05 +03:00
|
|
|
# |
|
|
|
|
# 1 | 10/2009/09;Flubber Co🎅;50;
|
|
|
|
# | ^^^^^^^^^^
|
|
|
|
# well-formed but invalid date: 10/2009/9
|
2019-06-07 00:37:36 +03:00
|
|
|
# <
|
2018-09-07 23:43:05 +03:00
|
|
|
# 10/2009/09;Flubber Co🎅;50;
|
|
|
|
# 11/2009/09;Flubber Co🎅;;50
|
2019-10-12 23:12:50 +03:00
|
|
|
# RULES
|
|
|
|
# account1 Assets:MyAccount
|
|
|
|
# date %1
|
|
|
|
# date-format %d/%Y/%m
|
|
|
|
# description %2
|
|
|
|
# amount-in %3
|
|
|
|
# amount-out %4
|
|
|
|
# currency $
|
|
|
|
# $ ./hledger-csv
|
2018-09-07 23:43:05 +03:00
|
|
|
# 2009/09/10 Flubber Co🎅
|
|
|
|
# Assets:MyAccount $50
|
2019-10-12 23:58:11 +03:00
|
|
|
# expense:unknown $-50
|
2018-09-07 23:43:05 +03:00
|
|
|
#
|
|
|
|
# 2009/09/11 Flubber Co🎅
|
|
|
|
# Assets:MyAccount $-50
|
|
|
|
# expenses:unknown $50
|
|
|
|
#
|
2019-06-07 00:37:36 +03:00
|
|
|
# >=0
|
2018-09-07 23:43:05 +03:00
|
|
|
|
2019-06-07 00:37:36 +03:00
|
|
|
# . reading TSV (tab-separated) TODO user error (CSV record ["10/2009/09\tFlubber Co\127877\t50\t"] has less than two fields)
|
|
|
|
# <
|
2018-09-07 23:43:05 +03:00
|
|
|
# 10/2009/09 Flubber Co🎅 50
|
|
|
|
# 11/2009/09 Flubber Co🎅 50
|
2019-10-12 23:12:50 +03:00
|
|
|
# RULES
|
|
|
|
# account1 Assets:MyAccount
|
|
|
|
# date %1
|
|
|
|
# date-format %d/%Y/%m
|
|
|
|
# description %2
|
|
|
|
# amount-in %3
|
|
|
|
# amount-out %4
|
|
|
|
# currency $
|
|
|
|
# $ ./hledger-csv
|
2018-09-07 23:43:05 +03:00
|
|
|
# 2009/09/10 Flubber Co🎅
|
|
|
|
# Assets:MyAccount $50
|
2019-10-12 23:58:11 +03:00
|
|
|
# expense:unknown $-50
|
2018-09-07 23:43:05 +03:00
|
|
|
#
|
|
|
|
# 2009/09/11 Flubber Co🎅
|
|
|
|
# Assets:MyAccount $-50
|
|
|
|
# expenses:unknown $50
|
|
|
|
#
|
2019-06-07 00:37:36 +03:00
|
|
|
# >=0
|