Giter Club home page Giter Club logo

dex-parse's Introduction

Build Status Coverage Status

dex-parse

Dex-parse is a node.js library for parsing raw vending machine audit data in the DEX/UCS format into plain JS objects. Currently supports basic product sales and machine data, with support for remaining fields planned as needed.

Input

DEX data is new line (\n) delimited text where each line contains 2 or 3 character prefix denoting the type of record. Fields within a record are delimited by '*', and the interpretation depends on the type of record.

DXS*WTN4213952*VA*V0/6*1
ST*001*0001
ID1*WTN11082110074*GVC1        *8207***
ID4*2*001*5
CB1*11082110074*GVC1        *8207
PA1*010*50*****
PA2*6*350*6*350*0*0*0*0*0*0*0*0
PA3*2*150*2*150
PA4*0*0*0*0
PA5*20120301*125320*0

Output

Output is a single JS object containing an array of products and machine data properties. Data is typed where possible; for example, price information is returned as Number.

Example output

Output for the example given above would be:

{
  "products": [
    {
      "name": "010",
      "price": 0.5,
      "sold": 6,
      "revenue": 3.5,
      "testVendCount": "2",
      "soldOutDate": "20120301",
      "soldOutTime": "125320",
      "soldOutCount": "0"
    }
  ],
  "machine": {
    "serialNumber": "WTN11082110074",
    "modelNumber": "GVC1",
    "buildStandard": "8207",
    "assetNumber": "",
    "controlBoard": {
      "serialNumber": "11082110074",
      "modelNumber": "GVC1",
      "softwareRevision": "8207"
    }
  }
}

Example Usage

Input data can be passed directly as string or read from a file.

var dexparse = require('dex-parse')

var mytext = "..."
dexparse.readText(mytext, function(err, data) {
    console.log(data.products[0].name)
})

dexparse.readFile('myfile.dex', function(err, data) {
    console.log(data.products[0].name)
})

License

Dex-parse is licensed under the MIT license. See LICENSE.txt.

dex-parse's People

Contributors

mdisibio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.