Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

fwv

tests cover size

A ⚡️ crazy fast streaming ⚡️ Fixed Width Value Parser

This module is mostly useful to folks who have to parse fixed-width format files. Fixed-width files are often created from database reports or from Microsoft Excel. However, this module can also be used to quickly parse a string containing data at specified locations.

Note: This module requires Node v8.11.0 or higher.

Install

Using npm:

$ npm install fwv

Using yarn:

$ yarn add fwv

Usage

const fwv = require('fwv');

const options = {
  columns: [
    { name: 'id', from: 0, to: 4 },
    { name: 'name', from: 5, to: 11 },
    { name: 'cost', from: 12, to: 16 }
  ],
  input: '0001 WIDGET 5.00'
}

const result = await fwv(options);

//→ [ { id: '0001', name: 'WIDGET', cost: '5.00' }]

API

fwv([options])

Returns: Array[object]

options

Type: object

columns

Type: Array[object]

An array of column configurations. Each item in the array will correspond to a property on the result for a given line.

  {
    name: <string>,  // the name of the column / result object property
    from: <integer>, // the start position of the column
    to: <integer>    // the end position of the column
  }

Note: For an example column configuration, see test/fixtures/config.js.

input

Type: string|Buffer|Stream

An input value, upon which the parser will run.

Passing a readable Stream is preferred, but you may pass a string or Buffer, and the module will convert it to a Stream for you.

Meta

CONTRIBUTING

LICENSE (MIT)

About

A ⚡️ crazy fast streaming ⚡️ Fixed Width Value Parser

Topics

Resources

License

Packages

No packages published
You can’t perform that action at this time.