Skip to content

Instantly share code, notes, and snippets.

@beaugunderson
Last active Aug 29, 2015
Embed
What would you like to do?
'use strict';
var fs = require('fs');
var parse = require('csv-parse');
var _ = require('lodash');
var stream = fs.createReadStream('./responses.csv');
var parser = parse({columns: true}, function (ignoredError, rows) {
rows.forEach(function (row, i) {
console.log('<h1>Response %d</h1>', i + 1);
console.log('<dl>');
_.forOwn(row, function (value, key) {
console.log('<dt><strong>%s:</strong></dt>', key);
console.log('<dd>%s</dd>', value.trim().replace(/\n/g, '<br>'));
});
console.log('</dl>');
});
});
stream.pipe(parser);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment