var fs = require('fs');
var CsvReadableStream = require('csv-reader');
var AutoDetectDecoderStream = require('autodetect-decoder-stream');
var inputStream = fs.createReadStream('my_data.csv')
.pipe(new AutoDetectDecoderStream({ defaultEncoding: '1255' })); // If failed to guess encoding, default to 1255
// The AutoDetectDecoderStream will know if the stream is UTF8, windows-1255, windows-1252 etc.
// It will pass a properly decoded data to the CsvReader.
inputStream
.pipe(CsvReader({ parseNumbers: true, parseBooleans: true, trim: true }))
.on('data', function (row) {
console.log('A row arrived: ', row);
}).on('end', function (data) {
console.log('No more rows!');
});
Guess it should look like this (CsvReader ->CsvReadableStream, like in your github readme):
var fs = require('fs');
var CsvReadableStream = require('csv-reader');
var AutoDetectDecoderStream = require('autodetect-decoder-stream');
var inputStream = fs.createReadStream('my_data.csv')
.pipe(new AutoDetectDecoderStream({ defaultEncoding: '1255' })); // If failed to guess encoding, default to 1255
// The AutoDetectDecoderStream will know if the stream is UTF8, windows-1255, windows-1252 etc.
// It will pass a properly decoded data to the CsvReader.
inputStream
.pipe(CsvReadableStream({ parseNumbers: true, parseBooleans: true, trim: true }))
.on('data', function (row) {
console.log('A row arrived: ', row);
}).on('end', function (data) {
console.log('No more rows!');
});
Hi! I noticed you have typo in example in your npm readme. https://www.npmjs.com/package/csv-reader#usage-example
Guess it should look like this (CsvReader ->CsvReadableStream, like in your github readme):