diff --git a/Readme.md b/Readme.md index c8d5112..b1b1ce8 100644 --- a/Readme.md +++ b/Readme.md @@ -71,7 +71,12 @@ The options are also passed to the underlying transform stream, so you can pass objectMode: false, // if set to true, uses first row as keys -> [ { column1: value1, column2: value2 }, ...] - columns: false + columns: false, + + // each csv column name is optionally mapped to this so its value can be transformed + columnTransform: function(name) { + return name + } } ``` diff --git a/csv-streamify.js b/csv-streamify.js index 32f2633..254853e 100644 --- a/csv-streamify.js +++ b/csv-streamify.js @@ -16,6 +16,7 @@ module.exports = function (opts, cb) { opts.empty = opts.hasOwnProperty('empty') ? opts.empty : '' opts.objectMode = opts.objectMode || false opts.hasColumns = opts.columns || false + opts.columnTransform = opts.columnTransform || function (l) { return l } // state var state = { @@ -41,7 +42,7 @@ function createParser (opts, state) { if (opts.hasColumns) { if (state.lineNo === 0) { - state._columns = state._line + state._columns = state._line.map(opts.columnTransform) state.lineNo += 1 reset() return