The File
API suggested by papaparse's docs is meant for browser used. Assuming that you are running this on node at server side, what works for me is leveraging the readable stream:
const fs = require('fs');
const papa = require('papaparse');
const file = fs.createReadStream('challenge.csv');
var count = 0; // cache the running count
papa.parse(file, {
worker: true, // Don't bog down the main thread if its a big file
step: function(result) {
// do stuff with result
},
complete: function(results, file) {
console.log('parsing complete read', count, 'records.');
}
});
There may be an easier interface, but so far this works quite well and offer the option of streaming for processing large files.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…