Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
```

Expand Down
3 changes: 2 additions & 1 deletion csv-streamify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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
Expand Down