Importers and metadata

146 views
Skip to first unread message

alessandr...@runbox.com

unread,
Nov 26, 2018, 6:03:42 PM11/26/18
to beancount
Hi,

I'm in the process of writing an importer for a CSV obtained from a bank. While I don't have a problem handling most of the transaction information, the file also contains some extra data that I would like to keep as metadata (for the relevant transactions). However, I can't seem to find a way to do this. Does the importer framework from beancount.ingest allow to include metadata with parsed transactions? For example, this csv data

"transaction id", date, amount, description, payee, "payee account number"
sepa-123, 26-11-2018, 100, "example transaction", "ACME GmbH", "333555777"

would result in something like

2018-11-19 * "ACME GmbH" "example transaction"
payee-account: "333555777"
Assets:MyBank:CurrentAccount -100 EUR
Expenses:Example

Also, could you explain to me which data is better represented as a tag, and which as a link? I'm sure this should have popped up time and again, but I couldn't find a satisfactory answer after looking through the documentation and the mailing list archives.

Best wishes,
Alessandro

Daniele Nicolodi

unread,
Nov 26, 2018, 8:03:11 PM11/26/18
to bean...@googlegroups.com
Hi Alessandro,

On 26-11-2018 16:03, alessandr...@runbox.com wrote:
> I'm in the process of writing an importer for a CSV obtained from a bank. While I don't have a problem handling most of the transaction information, the file also contains some extra data that I would like to keep as metadata (for the relevant transactions). However, I can't seem to find a way to do this. Does the importer framework from beancount.ingest allow to include metadata with parsed transactions?

The constructor for a transactions (and most other directives) takes a
dictionary as a `meta` parameter. All keys in this dictionary (except
'filename' and 'lineno') are translated into metadata attached to the
directive. For example I use this to record an unique identifier for
each transaction, using the "transaction id" assigned to the transaction
by the bank, or similar mechanism.

> Also, could you explain to me which data is better represented as a tag, and which as a link? I'm sure this should have popped up time and again, but I couldn't find a satisfactory answer after looking through the documentation and the mailing list archives.

There are some hints on how to use those features in the Tags ans Links
sections of the Language Syntax document:
http://furius.ca/beancount/doc/syntax.

There is not an unique way of using links and tags (as is the case with
other pieces of information attached to transactions). Links are more
appropriate to link a set of transactions together, while tags are more
of a categorization feature.

In general I would not worry too much about how you record (or don't)
the information. It is very easy to refactor the input files at a later
stage if you will find that initial choices will not allow to perform
some operation in the future. Just start using the basic features and
evolve over time.

Cheers,
Dan
Reply all
Reply to author
Forward
0 new messages