etcsv
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

etcsv

etcsv(.js) is node.js library to edit a table for CSV database.

"Editing Table for CSV"

Code Climate

Install

$ npm install etcsv

Usage

var etcsv = require('etcsv');
 
var table = etcsv.imports('foo.csv');
 
table.setByFieldName('field-name', function (value, thisRecord, thisColumn) {
    return value.replace(/\n/, '<br>');
});
 
table.save(); // overwrite save
table.saveAs('newFile.csv'); // save as new file

etcsv Methods

etcsv.imports(filePath:String):etcsv.Table

Warning: Sync (not async) process. This is returned an instance of the etcsv.Table Class.

var table = etcsv.imports('foo.csv');

Table Class Methods

var table = etcsv.imports('foo.csv');

table.setByFieldName(fieldName:String, callback:Function):void

This is fired records for set field name every time callback process. By returning value to the callback function, edit a value of that field. If return undefined, or does not return a value, a field value is not changed. But, if return null or 0, a field value will be overwritten by it.

table.setByFieldName('field-name', function (value, thisRecord) {
    return value.replace(/\n/, '<br>');
});

Dependencies (2)

Dev Dependencies (5)

Package Sidebar

Install

npm i etcsv

Weekly Downloads

1

Version

0.2.0

License

MIT

Last publish

Collaborators

  • yusukehirao