file-to-objects

Parse a property delimited file, line-by-line, and return the line in a JavaScript array in object representation.
fileToObjects(📄) => [ {}, {}, {} ]
Install
$ npm install --save file-to-objects
OR $ yarn add file-to-objects
Usage
const fileToObjects = require('file-line-parse');
const input = './data/CATS_DATA.csv';
const keys = [ 'name', 'breed', 'age', 'color'];
fileToObjects(input, { keys: keys })
.then(cats => {
console.log(cats[0])
console.log(cats[1])
});
API
fileToObjects(input, [options])
Return a set
of parsed objects dictacted by sequence of keys
Path to file to be input.
An array of keys to serve as a mapping for objects, this will override any column header to serve as a mapping for object creation.
options.delimiter | <string>
The delimiter to used for parsing. Default: ","
options.encoding | <string>
The encoding for reading the file. Default: "utf8"
Related
:arrows_counterclockwise: objects-to-file - Create a delimited value, output file from an array of objects.
License
MIT