vamtiger-csv-to-generator
v1.1.5
Published
Parse CSV file and reference it as a generator.
Downloads
15
Maintainers
Readme
VAMTIGER CSV to Generator
This defines a class for conveniently referencing CSV data as a Generator.
Installation
VAMTIGER Argv can be installed using npm:
npm install --save vamtiger-csv-to-generator
CSV Data
Column Tile 1; Column Title 2
Column 1 Row 2; Column 2 Row 1
Usage
CSV data can be referenced via a Generator getData method.
const path = require('path'),
VamtigerCsv = require('vamtiger-csv-to-generator'),
vamtigerCsv = new VamtigerCsv({
filePath: path.join(__dirname, 'data.csv'),
separator: ';'
});
// Get CSV data as a Generator
vamtigerCsv.getData
.then(data => {
const firstRow = data.next().value; // ["Column Tile 1","Column Title 2"]
const secondRow = data.next().value; // {"Column Tile 1":"Column 1 Row 2","Column Title 2":"Column 2 Row 1"}
data.next().value // undefined
})
// Optional, but recommended.
.catch(handleError); // e.g. Invalid path to CSV file