Skip to main content

Beancount DKB Importer

image image Downloads Ruff

beancount-dkb provides importers for converting CSV exports of DKB (Deutsche Kreditbank) account summaries to the Beancount format.

Installation

$ pip install beancount-dkb

In case you prefer installing from the Github repository, please note that main is the development branch so stable is what you should be installing from.

Usage

If you're not familiar with how to import external data into Beancount, please read this guide first.

Beancount 3.x

Beancount 3.x has replaced the config.py file based workflow in favor of having a script based workflow, as per the changes documented here. The beangulp examples suggest using a Python script based on beangulp.Ingest. Here's an example of how that might work:

Add an import.py script in your project root with the following contents:

from beancount_dkb import ECImporter, CreditImporter
from beangulp import Ingest

importers = (
    ECImporter(
        "DE99 9999 9999 9999 9999 99",
        'Assets:DKB:EC',
        currency='EUR',
    ),

    CreditImporter(
        "9999 9999 9999 9999",
        'Assets:DKB:Credit',
        currency='EUR',
    ),
)

if __name__ == "__main__":
    ingest = Ingest(importers)
    ingest()

... and run it directly using python import.py extract.

Beancount 2.x

Adjust your config file to include ECImporter and CreditImporter (depending on what account you're trying to import).

Add the following to your config.py.

from beancount_dkb import ECImporter, CreditImporter

CONFIG = [
    ECImporter(
        "DE99 9999 9999 9999 9999 99",
        "Assets:DKB:EC",
        currency='EUR',
    ),

    CreditImporter(
        "9999 9999 9999 9999",
        "Assets:DKB:Credit",
        currency='EUR',
    ),
]

Once this is in place, you should be able to run bean-extract on the command line to extract the transactions and pipe all of them into your Beancount file.

$ bean-extract /path/to/config.py transaction.csv >> you.beancount

Ignoring Credit Card Settlement Transactions

DKB credit card CSV exports may contain settlement transactions such as Ausgleich Kreditkarte. If these settlements are already imported through the EC account, configure the CreditImporter to ignore and skip them during import.

Beancount 3.x

from beancount_dkb import CreditImporter
from beangulp import Ingest

importers = (
    CreditImporter(
        "9999 9999 9999 9999",
        "Assets:DKB:Credit",
        ignore_credit_card_settlements=True,
    ),
)

if __name__ == "__main__":
    ingest = Ingest(importers)
    ingest()

Beancount 2.x

CONFIG = [
    CreditImporter(
        CARD_NUMBER,
        'Assets:DKB:Credit',
        ignore_credit_card_settlements=True,
    )
]

Transaction Codes as Meta Tags

By default, the ECImporter prepends the transaction code ("Buchungstext") to the transaction description. To achieve shorter descriptions and use meta tags to query for certain transaction codes, the importer may be configured to store the transaction code in a user provided meta tag.

Add the meta_code parameter when instantiating an ECImporter.

Beancount 3.x

from beancount_dkb import ECImporter
from beangulp import Ingest

importers = (
    ECImporter(
        "DE99 9999 9999 9999 9999 99",
        "Assets:DKB:EC",
        meta_code="code',
    ),
)

if __name__ == "__main__":
    ingest = Ingest(importers)
    ingest()

Beancount 2.x

...
CONFIG = [
    ECImporter(
        IBAN_NUMBER,
        'Assets:DKB:EC',
        currency='EUR',
        meta_code='code',
    ),
...

This is how an example transaction looks without the option:

2021-03-01 * "Kartenzahlung" "XY Supermarket"
    Assets:DKB:EC                        -133.72 EUR

And this is the resulting transaction using meta_code='code'

2021-03-01 * "XY Supermarket"
    code: Kartenzahlung
    Assets:DKB:EC                        -133.72 EUR

Payee Address Spacing

Some DKB EC exports append an address to the payee with a long run of filler spaces. ECImporter keeps payees unchanged by default, but can collapse those space runs to a single space when configured with normalize_payee_address_spacing=True.

ECImporter(
    IBAN_NUMBER,
    "Assets:DKB:EC",
    normalize_payee_address_spacing=True,
)

Pattern-matching Transactions

It's possible to give the importer classes hints if you'd like them to include a second posting based on specific characteristics of the original transaction.

For instance, if the payee, description, or counterparty IBAN in a transaction always matches a certain value, it's possible to tell the ECImporter or CreditImporter to automatically place a second posting in the returned list of transactions.

ECImporter

ECImporter accepts payee_patterns and description_patterns arguments, which should be a list of (pattern, account) tuples. The pattern is compiled using re.compile, so feel free to use regular expressions there.

ECImporter also accepts an iban_matcher argument, which should be a list of (iban, account) tuples. The IBAN is normalized by removing whitespace and uppercasing before being compared exactly against the counterparty IBAN field in current DKB EC exports. iban_matcher is not available for legacy exports (before 2023). So, it is ignored for those files.

Beancount 3.x
from beancount_dkb import ECImporter
from beangulp import Ingest

importers = (
    ECImporter(
        "DE99 9999 9999 9999 9999 99",
        "Assets:DKB:EC",
        payee_patterns=[
            ("REWE", "Expenses:Supermarket:REWE"),
            (r"N*TFL*X", "Expenses:Online:Netflix"),
        ],
        iban_matcher=[
            ("DE88 8888 8888 8888 8888 88", "Assets:Bank:HYSA"),
        ],
    ),
)

if __name__ == "__main__":
    ingest = Ingest(importers)
    ingest()
Beancount 2.x
CONFIG = [
    ECImporter(
        IBAN_NUMBER,
        "Assets:DKB:EC",
        currency='EUR',
        payee_patterns=[
            ("REWE", "Expenses:Supermarket:REWE"),
            ("NETFLIX", "Expenses:Online:Netflix"),
        ],
        iban_matcher=[
            ("DE88 8888 8888 8888 8888 88", "Assets:Bank:HYSA"),
        ],
    ),

CreditImporter

CreditImporter accepts a description_patterns argument, which should be a list of (pattern, account) tuples.

Beancount 3.x
from beancount_dkb import CreditImporter
from beangulp import Ingest

importers = (
    ECImporter(
        "9999 9999 9999 9999",
        "Assets:DKB:EC",
        currency="EUR",
        payee_patterns=[
            ("REWE", "Expenses:Supermarket:REWE"),
            ("NETFLIX", "Expenses:Online:Netflix"),
        ],
    ),
)

if __name__ == "__main__":
    ingest = Ingest(importers)
    ingest()
Beancount 2.x
CONFIG = [
    CreditImporter(
        CARD_NUMBER,
        'Assets:DKB:Credit',
        currency='EUR',
        description_patterns=[
            ('REWE', 'Expenses:Supermarket:REWE'),
            ('NETFLIX', 'Expenses:Online:Netflix'),
        ],
    )

Contributing

Contributions are most welcome!

Please make sure you have Python 3.10+ and Poetry installed.

  1. Clone the repository: git clone https://github.com/siddhantgoel/beancount-dkb
  2. Install the packages required for development: poetry install
  3. That's basically it. You should now be able to run the test suite: poetry run task test.

Release files for beancount-dkb 1.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for beancount-dkb 1.10.0
File Size Uploaded
beancount_dkb-1.10.0.tar.gz 12.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for beancount-dkb 1.10.0
File Interpreter ABI Platform
beancount_dkb-1.10.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.7 kB

Release files / beancount_dkb-1.10.0.tar.gz

Download URL beancount_dkb-1.10.0.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e1bc4fc854b3bbfe73a7849e83a6c40c93c1dd450f5b4447ce456510a70e6e35
BLAKE2b-256 checksum
How to use checksums
e4799f4fb6780f4065dcd26c68dfc36afba50790aa766686f289670bb4651cb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 12, 2026.

Transparency log

Release files / beancount_dkb-1.10.0-py3-none-any.whl

Download URL beancount_dkb-1.10.0-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
76bcc0d0740194464e6395629a0130268a7907cd2e8bf08f91f15a25264d1fa4
BLAKE2b-256 checksum
How to use checksums
da959beeed0860328cf6d5b2c0caa6a38b4ec65b5d408e9b4c5a21f6660117cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.10.0 This release

2 release files

1.9.0

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.18.0

2 release files

0.17.0

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page