vamtiger-csv-to-generator

1.1.5 • Public • Published

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

Package Sidebar

Install

npm i vamtiger-csv-to-generator

Weekly Downloads

2

Version

1.1.5

License

MIT

Last publish

Collaborators

  • vamtiger-project