Skip to content

Instantly share code, notes, and snippets.

@navidshaikh
navidshaikh / gist:4147217
Created November 26, 2012 08:36 — forked from syntagmatic/gist:2202660
Export CSV with Javascript
// assumes variable data, which is a homogenous collection of objects
// get keys
var keys = _.keys(data[0]);
// convert to csv string
var csv = keys.join(",");
_(data).each(function(row) {
csv += "\n";
csv += _(keys).map(function(k) {