Skip to main content

Parser and query API for bank CSV account transactions

Project description

Elv

Elv is a small utility for parsing exported CSV files from the online Norwegian bank Jæren Sparebank.

I use it for personal purposes, but decided to simply upload the code anyway, in case anyone wants to do the same.

If you want to contribute other formats, please send pull requests on the project’s GitHub page at

Use the “export data” feature in the online bank, and you should be able to parse the file using Elv.

Features

  • Parses CSV file from bank containing transactions

  • Money is stored in exact decimals (as you should do; never use floats for stuff like this)

  • Contains a simple Python query API for sorting through large collections of transactions.

  • Can optionally put transactions in an in-memory SQLite3 database for even better queries.

Norwegian short description

Elv er en Python modul for å lese banktransaksjoner eksportert fra banken din som en CSV-fil. Foreløpig er det kun Jæren Sparebank som jeg vet er støttet, men du kan nok ganske enkelt legge til lesere for andre format.

Installation

You can install from setup.py:

$ python setup.py install # you may have to run as sudo

or from PyPI:

$ pip install elv

Example usage

If you have the bank account transactions in a file called data.csv, you can simply do:

$ python
>>> import elv
>>> transactions = elv.parse("data.csv")
>>> transactions
<Transactions:400 items from 2009-01-27 to 2014-09-29>
>>> transactions[0]
<Transaction:2014-09-29 2014-09-29 -2677.00  29519.13 'Vacation'>
>>> transactions[0].xfer
datetime.date(2014, 9, 29)
>>> transactions[0].posted
datetime.date(2014, 9, 29)
>>> transactions[0].amount
Decimal('-2677.00')

You can also get an in-memory SQLite3 database by doing:

>>> db = transactions.to_sqlite3()
>>> db
<sqlite3.Connection object at 0x10f31e200>
>>> db.execute("SELECT * FROM Transactions").next()
(0, datetime.date(2014, 9, 29), datetime.date(2014, 9, 29),
 u'Vacation', Decimal('-2677'), Decimal('29519.13'))

The CSV File Format

The CSV file should be a plain text file with the ISO-8859-1 encoding (aka Latin1). It looks like this:

"31-12-2014";"31-12-2014";"Test 1";"-497,78";"5.520,09"
"30-12-2014";"31-12-2014";"Test 2";"-100,00";"6.017,87"
"30-12-2014";"31-12-2014";"Test 3 --æøåÆØÅ--";"-145,47";"6.117,87"
"30-12-2014";"30-12-2014";"Test 4";"-457,24";"6.263,34"
"29-12-2014";"29-12-2014";"Test 5";"-108,30";"6.720,58"

The fields are as follows:

  • Date when the transaction was placed, in format "DD-MM-YYYY".

  • Date when the transaction was posted (“bokført”).

  • A message associated with the transaction, set by the one making the transaction.

  • The amount deposited or deducted from the account in NOK (Norwegian kroner) in format "-123,45", always two decimals and an optional sign.

  • The balance of your account after this transaction was completed.

The file itself contains no headers, and can contain many such transactions, one per line.

License

Copyright (C) 2015 Christian Stigen Larsen

Licensed under AGPL v3 or later; see http://www.gnu.org/licenses/agpl-3.0.html

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

elv-1.0.1.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

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

elv-1.0.1-py2-none-any.whl (8.6 kB view details)

Uploaded Python 2

File details

Details for the file elv-1.0.1.tar.gz.

File metadata

  • Download URL: elv-1.0.1.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for elv-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b091a2ca94d847cbd183c1649d64901bbc6844fe758af1b2285764b9b6c34053
MD5 0cf431845201f471ceb755a6c432e3ed
BLAKE2b-256 e0d28580c818ae98854f79a02cd232a597f56c789f908f98e2f8947109331ef0

See more details on using hashes here.

File details

Details for the file elv-1.0.1-py2-none-any.whl.

File metadata

  • Download URL: elv-1.0.1-py2-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for elv-1.0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 943d32dfd19fa15d1a42d87f108cbdc50d41e9b7adad77668d337ac9ee8fdaac
MD5 57847fc0268b3e9915a6f17091e144be
BLAKE2b-256 04f2cffc336b09068038a1ed157f507fd2bc128f626f7a6b40af8722135d9b8f

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