Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

etcsv

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>');
});

Install

npm i etcsv

DownloadsWeekly Downloads

2

Version

0.2.0

License

MIT

Last publish

Collaborators

  • avatar