Write to a CSV in Node.js

I am struggling to find a way to write data to a CSV in Node.js.

There are several CSV plugins available however they only 'write' to stdout. Ideally I want to write on a row-by-row basis using a loop.

Thanks in advance.

The docs for node-csv-parser (npm install csv) specifically state that it can be used with streams (see fromStream, toStream). So it's not hard-coded to use stdout.

Several other CSV parsers also come up when you npm search csv -- you might want to look at them too.