Closed ashley-jisc closed 1 year ago
Hi @ashley-jisc ,
The example is wrong. I will fix it.
You should use the listeners on the parser:
import { createReadStream, createWriteStream } from 'fs';
import { Transform } from '@json2csv/node';
const input = createReadStream(inputPath, { encoding: 'utf8' });
const output = createWriteStream(outputPath, { encoding: 'utf8' });
const parser = new Transform();
const processor = input.pipe(parser).pipe(output);
// You can also listen for events on the conversion and see how the header or the lines are coming out.
parser
.on('header', (header) => console.log(header))
.on('line', (line) => console.log(line))
When looking at the examples, there are references to a
json2csv
but it's not imported in the code examples.For instance the Node Transform example:
Where does json2csv come from? There only appears to be a
AsyncParser
andTransform
exported from @json2csv/node.