Git Product home page Git Product logo

ctx_parser's Introduction

Build Status Coverage Status

About

ctx_parser is a parser written with pyparsing for the .ctx format used by AqBanking.

Usage

In [1]: from ctx_parser import parser

In [2]: accounts = parser.LIST.parseFile('accounts.ctx')

In [3]: accounts.accountInfoList[0].accountNumber
Out[3]: '987654300'

In [4]: accounts.accountInfoList[0].accountId
Out[4]: 0

In [5]: accounts.accountInfoList[0].statusList[0].bookedBalance.value.value
Out[5]: 23.42

In [6]: accounts.accountInfoList[0].statusList[0].bookedBalance.time
Out[6]: datetime.datetime(2014, 5, 4, 1, 42, 23)

where accounts.ctx contains a LIST of (more or less) complex elements:

% cat accounts.ctx
accountInfoList {
  accountInfo {
    char bankCode="12345678"
    char bankName="Bad Bank"
    char accountNumber="987654300"
    char accountName="personal account"
    char iban="CC42123456780987654300"
    char bic="COUNCOBB423"
    char owner="Smith, John"
    char currency="USD"
    int  accountType="0"
    int  accountId="0"

    statusList {
      status {
        int  time="1399068000"

        bankLine {
          char value="1000"
          char currency="USD"
        } #bankLine

        bookedBalance {
          value {
            char value="2342%2F100"
            char currency="USD"
          } #value

          int  time="1399068000"
        } #bookedBalance
      } #status
    } #statusList
  } #accountInfo
} #accountInfoList
%

Disclaimer

The grammar for this parser has been extrapolated from example files and may, although tending to underfit the perceived rules, be unable to describe constructs I didn't foresee/encounter.

If you come across an unparsable .ctx file, feel free to file an issue, providing a reproducing example. Better yet, fork, add a reproducing test, extend the parser and send a pull request :)

Let me know how it goes, dtk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.