hledger/examples/csv/tarsnap.csv.rules
2017-04-19 08:24:23 -07:00

38 lines
2.1 KiB
Plaintext

# hledger CSV conversion rules for tarsnap.com's "Recent activity (all machines)"
#
# RECTYPE,DATE,MACHINE,TYPE,QUANTITY,AMOUNT,BALANCE
# Balance,2016-12-28,,,,,28.396910846961952530
# Usage,2016-12-28,machine1,Client->Server bandwidth,729977109,0.182494277250000000,
# Usage,2016-12-28,machine1,Daily storage,94917624870,0.765464704446112920,
# Usage,2016-12-28,machine1,Server->Client bandwidth,132739070,0.033184767500000000,
skip 1
fields rectype,date,machine,type,quantity,amount,balance
account1 assets:tarsnap
if ^Balance,
description %rectype: $%balance
account1 dummy
account2 dummy
amount $0
# TODO zero amount is always rendered without commodity symbol
if ^Usage,
description %machine %type
account2 expenses:tarsnap:%machine:%type
amount -%quantity bytes @@ $%amount
# sample output:
# $ hledger -f tarsnap.csv bal -B cur:\\$ -MAT expenses
# using conversion rules file tarsnap.csv.rules
# Balance changes in 2016/12/01-2017/02/28:
#
# || 2016/12 2017/01 2017/02 Total Average
# ====================================================++===================================================================================================================
# expenses:tarsnap:machine1:Client->Server bandwidth || $0.724738970500000000 $4.479661574000000000 $1.922747437750000000 $7.127147982250000000 $2.375715994083333333
# expenses:tarsnap:machine1:Daily storage || $3.031766211919159188 $23.945385100696412904 $8.584370624209118831 $35.561521936824690923 $11.853840645608230308
# expenses:tarsnap:machine1:Server->Client bandwidth || $0.196816259250000000 $0.798626419000000000 $0.273752084250000000 $1.269194762500000000 $0.423064920833333333
# ----------------------------------------------------++-------------------------------------------------------------------------------------------------------------------
# || $3.953321441669159188 $29.223673093696412904 $10.780870146209118831 $43.957864681574690923 $14.652621560524896974