This package has been deprecated

Author message:

WARNING: file-line-parse has been renamed to file-to-objects, visit https://www.npmjs.com/package/file-to-objects

file-line-parse

1.0.4 • Public • Published

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

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

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i file-line-parse

Weekly Downloads

8

Version

1.0.4

License

MIT

Last publish

Collaborators

  • brh55