TypeError: Cannot read properties of undefined (reading 'charCodeAt') - when reading empty file
mirelon opened this issue · comments
const readStream = fs.createReadStream(inputCsv, 'utf-8')
await readStream
.pipe(
new CsvReadableStream({parseNumbers: false, trim: true, skipHeader: false, skipEmptyLines: true})
)
.on('data', () => {
logger.info('new data')
})
.on('end', () => {
logger.info('end')
});
When supplied with empty input file, then following error occurs:
~/project/node_modules/csv-reader/index.js:111
if (newData.charCodeAt(0) === 0xfeff) {
^
TypeError: Cannot read properties of undefined (reading 'charCodeAt')
at CsvReadableStream._processChunk (~/project/node_modules/csv-reader/index.js:111:25)
at CsvReadableStream._flush (~/project/node_modules/csv-reader/index.js:287:14)
@danielgindi is anyone working on this issue? I think it is just an edge case where we need to provide a user friendly error.
There should not be an error for an empty csv :)
You can open a PR, or wait a bit for me to get to it
Released in 1.0.9