Skip to content
This repository was archived by the owner on Jan 9, 2018. It is now read-only.

Conversation

@jczaplew
Copy link

This addresses one bug and introduces one feature. As with a few other pending pull requests, this introduces the ability to add headers to the CSV output by adding a boolean parameter to res.csv. I have been using this in production for a few months now with no issues.

Additionally, this pull request adds a check to escape to make sure that numbers are properly parsed as such, and are not surrounded by quotes in the output. This has proven useful, as it increases the likelihood that an application like Excel will properly recognize the data type of a field (i.e. numbers are numbers, and not strings).

Thanks!

@xcarpentier
Copy link

Maybe it's little bit far-fetched but in waiting (I'm using flatten and lodash too) :

var flat = _.map(contacts, function(item){
 return flatten(item);
});
var keys = _.reduce(_.keys(flat[0]), function(result, item){
 result[item] = item;
 return result;
}, {});
res.csv([keys].concat(flat));

I hope this code help someone... ;-)

@jczaplew jczaplew closed this Jan 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants