Last active
August 29, 2015 14:11
-
-
Save beaugunderson/35cb60c577c28eaea924 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '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