1.0.4 • Published 7 years ago

file-line-parse v1.0.4

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

file-line-parse Travis XO code style

Parse a property delimited file, line-by-line, and return the line in a JavaScript array in object representation.

fileLineParse(📄) => {}, {}, {}

Install

$ npm install --save file-line-parse OR $ yarn add file-line-parse

Usage

// CATS_DATA.csv:
// Bubbles,Persian,24,honey-brown
// Garfield,Tabby,33,orange with stripes
const fileLineParse = require('file-line-parse');
const input = './data/CATS_DATA.csv';
const keys = [ 'name', 'breed', 'age', 'color'];
fileLineParse(input, keys)
.then(cats => {
    console.log(cats[0])
    // { name: 'Bubbles', breed: 'Persian', age: '24', color: 'honey-brown' }

    console.log(cats[1])
    // { name: 'Garfield', breed: 'Tabby', age: '33', color: 'orange with stripes' }
});

API

fileLineParse(input, keys, options)

Return a set of parsed objects dictacted by sequence of keys

input | <string>

Path to file to be input.

keys | <array>[<string> | <int>]

An array of keys to serve as mapping for object creation.

options | <object>

options.delimiter | <string>

Specify the delimiter to be used. Default: ","

Related

:arrows_counterclockwise: objects-to-file - Create a delimited value, output file from an array of objects.

License

MIT

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago