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
// CATS_DATA.csv:// Bubbles,Persian,24,honey-brown// Garfield,Tabby,33,orange with stripesconst fileToObjects = ;const input = './data/CATS_DATA.csv';const keys = 'name' 'breed' 'age' 'color'; ;
API
fileToObjects(input, [options])
Return a set
of parsed objects dictacted by sequence of keys
<string>
input | Path to file to be input.
<object>
options | <array>[<string> | <int>]
options.keys | 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.
<string>
options.delimiter | The delimiter to used for parsing. Default: ","
<string>
options.encoding | The encoding for reading the file. Default: "utf8"
Related
🔄 objects-to-file - Create a delimited value, output file from an array of objects.
License
MIT