Wednesday, 10 May 2017

Reading csv files using csv-parser, the browser file API, and webpack

I'd like to use the csv-parser module and the browser File API to read csv files via the browser.

The csv-parser node example looks like this:

    var csv = require('csv-parser')
    var fs = require('fs')

    fs.createReadStream('some-csv-file.csv')
      .pipe(csv())
      .on('data', function (data) {
        console.log('Name: %s Age: %s', data.NAME, data.AGE)
    })

How do I create the input for fs.createReadStream with the File API and is there anything besides importing the csv-parser into main.js required to get this working with webpack?



via Ole

No comments:

Post a Comment