Skip to main content

The simple library for extracting all kind of bank account transaction export files, mostly for beanhub-import to inject and generate transactions

Project description

beanhub-extract CircleCI

The simple library for extracting all kind of bank account transaction export files, mostly for beanhub-import to ingest and generate transactions

Note: This project is still in early stage, still subject to rapid major changes

Why?

Have you ever wondered why each of us has to write our own different Beancount importers for the same bank again and again? Why we cannot use the same exporter for the same bank CSV file? One of the biggest problems of the original Beancount importer design is that the transaction generation logic is coupled with the extract logic, making it hard to reuse. We are addressing the problem by creating a library only for extracting bank-exported CSV files into standardized transaction structures to be processed later. Ideally, you should be able to import this library and use it to import standardized transactions from CSV files exported from any bank in the world.

Install

pip install beanhub-extract

Example

Extracting transactions from the CSV file is easy. Simply create the extractor class and make a function call on the instance object, which will return a transaction object generator. Like this:

from beanhub_extract.extractors.mercury import MercuryExtractor

with open("/path/to/my-mercury.csv", "rt") as fo:
    extractor = MercuryExtractor(fo)
    for txn in extractor():
        print(txn)
        # process your transaction here

Sponsor

BeanHub logo

A modern accounting book service based on the most popular open source version control system Git and text-based double entry accounting book software Beancount.

Transaction data object

We defined a standardized transaction data object to accommodate a transaction statement's most commonly used columns. The data object type is a simple immutable Python dataclasses.dataclass class. It's defined in the beanhub_extract/data_types.py file.

Supported Formats

Currently, we only support a few banks for our own benefit. If you find any particular bank CSV file or format missing and want this library to support it, please feel free to open a PR.

Mercury - mercury

To export the CSV file, please visit the Transactions page and click "Add Filter" to limit the time range of your export, then click the "Export All" button on the right-hand side.

Chase

Chase Credit Card - chase_credit_card

To export the Chase Credit Card CSV file, please visit and login the Chase website. Expand the credit card details by clicking on the card you would like to export. Click the "Download account activity" button on the right hand side of the Account activity section. Click the "Download" button after you select the activity time range to "Year to date".

CSV - csv

In many cases, you have your own tools extracting transaction data into CSV files. Without implementing your own beanhub-extract extractor, you won't be able to ingest the data with beanhub-import. To make it much easier for cases like this, we also provide the csv extractor. With that, you can extract transactions into this standard CSV file as long as the fields name are defined in the Transaction dataclass. Only the following metadata fields are not supported (as they will be generated and assigned by the extractor):

  • extractor
  • file
  • lineno
  • reversed_lineno

There are a few fields with non-string types, their format are defined as below:

Date

The date and post_date should be in YYYY-MM-DD format.

Datetime

The timestamp should be in iso8601 format.

Bool

The pending field should be either ture or false (case-insensitive)

Wealthsimple - wealthsimple

To export the Wealthsimple CSV file, please visit and login the Wealthsimple website. Click on your Profile icon located in the top-right corner, then select "Documents" from the dropdown menu. Click "Request documents" in the top-right corner and choose "Activities export (CSV)" for transaction history. Select the reporting period and the accounts you want to export, then click "Download CSV" to download the file.

Fidelity - fidelity

To export the Fidelity CSV file, please visit and login the Fidelity website. Select your account from the left panel, then click on "Activity & Orders" followed by "History". The default view shows the past 30 days. To customize the period, click on the date range dropdown and select "Custom", then specify the "From Date" and "To Date" and click "Apply". Click the "Download" button, typically located in the upper-right corner, and choose the "CSV" format to download the file.

Citi - citi

To export the Citi CSV file, please visit and login the Citi website. Click on "Accounts" and select the specific account for which you want to export transactions. Scroll down to the "Transactions" section, then use the "Filter By" dropdown to select "All" transaction types and set a "Custom Date Range" for the period you want to export. Click the "Search" button to display the filtered transactions, then click on the download icon located in the top right corner of the transaction list. In the pop-up window, under "Text Formats," select "CSV" and click "Export" to download the file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

beanhub_extract-0.1.7.tar.gz (28.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

beanhub_extract-0.1.7-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file beanhub_extract-0.1.7.tar.gz.

File metadata

  • Download URL: beanhub_extract-0.1.7.tar.gz
  • Upload date:
  • Size: 28.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for beanhub_extract-0.1.7.tar.gz
Algorithm Hash digest
SHA256 88d874d016fa7ca031fae27753bf00fd631cdf29654c35a3693131d37751db50
MD5 b29f68e3912c98729dae15042b957342
BLAKE2b-256 2568e0a6fb55ec4a0ac9bf05782976db599ab950bc46e67cdf0d750bf7179b03

See more details on using hashes here.

File details

Details for the file beanhub_extract-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: beanhub_extract-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for beanhub_extract-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d791d47a3bb3bce0c72c4c15db2d6323e32405d2d5093e8a8d6f9c2d71b6029e
MD5 9227771cbed3f38e32e8f214937e0bde
BLAKE2b-256 2304a83d9d2789af59a9a5f0d4637db8176acdb9a10fdb340a26b7271a8bbb29

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page