node-generate-csv
This package intelligently orders the export to CSV
Install as an NPM module
$ npm install node-generate-csv
Usage
import { CreateExportCSV } from 'node-generate-csv'
or
const { CreateExportCSV } = require('node-generate-csv');
How to use
Basic
interface DataType {
year: number;
name: string;
hasADog?: boolean;
hasACat?:boolean
}
const data: DataType[] = [
{
year: 25,
name: "Ana"
},
{
year: 50,
name: "Thomas"
},
{
year: 18,
name: "Louise"
},
{
year: 20,
name: "Alex"
},
{
year: 46,
name: "Mark",
hasADog: true,
},
{
year: 38,
name: "Mariia",
hasACat: false,
}
]
new CreateExportCSV<DataType>(data, 'tmp/testfile')
Output
year,name,hasADog,hasACat
25,Ana,,,
50,Thomas,,,
18,Louise,,,
20,Alex,,,
46,Mark,true,,
38,Maria,,false