How to use csv

Comprehensive csv code examples:

How to use csv.stringify:

383
384
385
386
387
388
389
390
391
392
393
    res.writeHead(200, {
      'Content-Type': 'text/csv',
      //'Content-Length': stat.size,
      'Content-Disposition': 'attachment; filename=' + encodeURIComponent(fullmodelid + '.csv')
    });
    csv.stringify(rslt[fullmodelid], { quotedString: true }).pipe(res);
  });
};


return module.exports;

How to use csv.parse:

4
5
6
7
8
9
10
11
12
13
14
const PATH = require("path");
const FS = require("fs/promises");
const CSV = require("csv");


(async () => {
	const parser = CSV.parse(
		await FS.readFile(process.argv[2]),
		{
			columns: true
		}