Skip to content
Open
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
14 changes: 9 additions & 5 deletions lib/jsoncsv.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/jsoncsv.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class JsonCsv extends require('events').EventEmitter
# columns should be array of json nodes
return cb('error no data') unless data?
return cb('error please provide columns as options') unless columns?
data = JSON.stringify(data)
json = JSON.parse(data)
data = JSON.parse(data)
json = data[Object.keys(data)[0]]
for j in json
delete j['_events']
delete j['_id']
Expand All @@ -26,8 +26,9 @@ class JsonCsv extends require('events').EventEmitter
line += "," if field == null or field == undefined
else
if json[i] != undefined
line += json[i][index] + "," if json[i][index] != undefined
i = i + 1
line += json[i][index] if json[i][index] != undefined
line += "," if columns.slice(-1)[0] != index
i = i + 1
line += '\r\n'

line.slice 0, line.Length - 1
Expand Down