Standalone tools that aren’t linked to Beancount but that are useful with it.

The beancount.scripts package contains the implementation of scripts which invoke the Beancount library code. This pacakge implements other tools which aren’t directly invoking Beancount library code and which could be theoretically copied and used independently. However, these are to be distributed with Beancount and in order to maintain all the source code together they are put in this package and invokes from stubs under beancount/bin/, just like the other scripts.

Identify a column of text that contains hierarchical id and treeify that column.

This script will inspect a text file and attempt to find a vertically left-aligned column of text that contains identifiers with multiple components, such as “Assets:US:Bank:Checking”, and replace those by a tree-like structure rendered in ASCII, inserting new empty lines where necessary to create the tree.

Note: If your paths have spaces in them, this will not work. Space is used as a delimiter to detect the end of a column. You can customize the delimiter with an option.


A node with a name attribute, a list of line numbers and a list of children (from its parent class)., regexp_split)

Build up a tree from a list of matches.

  • column_matches – A list of (line-number, name) pairs.

  • regexp_split – A regular expression string, to use for splitting the names of components.


An instance of Node, the root node of the created tree., file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, prefix='')

Render a tree as a tree.

  • node – An instance of Node.

  • file – A file object to write to.

  • prefix – A prefix string for each of the lines of the children.

Accumulate the lines of a tree until a line number is found.


tree_lines – A list of lines as returned by render_tree.


Pairs of (line number, list of (line, node))., pattern, delimiter)

Find a valid column with hierarchical data in the text lines.

  • lines – A list of strings, the contents of the input.

  • pattern – A regular expression for the hierarchical entries.

  • delimiter – A regular expression that dictates how we detect the end of a column. Normally this is a single space. If the patterns contain spaces, you will need to increase this.


A tuple of
matches: A list of (line-number, name) tuples where ‘name’ is the

hierarchical string to treeify and line-number is an integer, the line number where this applies.

left: An integer, the leftmost column. right: An integer, the rightmost column.

Note that not all line numbers may be present, so you may need to skip some. However, they are in guaranteed in sorted order.

Render a tree of nodes.


A list of tuples of (first_line, continuation_line, node) where
first_line: A string, the first line to render, which includes the

account name.

continuation_line: A string, further line to render if necessary. node: The Node instance which corresponds to this line.

and an integer, the width of the new columns.