headers can be an array of strings to use as the header row. if you don't specify a header row the keys of the first row written to the stream will be used as the header row IF the first row is an object (see the test suite for more details). if the sendHeaders option is set to false, the headers will be used for ordering the data but will never be written to the stream.
This module also includes a CLI, which you can pipe ndjson to stdin and it will print csv on stdout. You can install it with npm install -g csv-write-stream.
$ csv-write --helpusage: csv-write [-h] [-v] [--separator SEPARATOR] [--newline NEWLINE] [--headers HEADERS [HEADERS ...]] [--no-send-headers]A CSV encoder stream that produces properly escaped CSVs. JSON is read fromSTDIN, formatted to CSV, and written to STDOUT.Optional arguments: -h, --help Show this help message and exit. -v, --version Show program's version number and exit. --separator SEPARATOR The separator character to use. Defaults to ','. --newline NEWLINE The newline character to use. Defaults to $'\n'. --headers HEADERS [HEADERS ...] The list of headers to use. If omitted, the keys of the first row written to STDIN will be used --no-send-headers Don't print the header row.