mholt / PapaParse

Fast and powerful CSV (delimited text) parser that gracefully handles large files and malformed input
http://PapaParse.com
MIT License
12.44k stars 1.14k forks source link

Example code for "Papa Parse for Node" section #663

Open btakita opened 5 years ago

btakita commented 5 years ago

I'm not correctly following the verbiage of what needs to be done. Could you add a code section with a simple example?

const stream = require('stream')
const { promisify } = require('util')
const finished = promisify(stream.finished)
async function parse(rs) {
    const a1__contact = []
    const rs__papaparse = Papa.parse(Papa.NODE_STREAM_INPUT, { header: true })
    rs.pipe(rs__papaparse)
    rs__papaparse.on('data', row => a1__contact.push(row))
    await finished(rs__papaparse)
}

https://github.com/mholt/PapaParse#papa-parse-for-node

vini-brito commented 2 years ago

Also this synchronous form works in Node:

const Papa = require('papaparse');

let parsedItems = Papa.parse(csvString);

console.log(parsedItems)