Handle CSV with power
- Fast and powerful (based on PapaParse)
- Handles nested CSV
- Extends Express response (
res.csv) - Sane defaults
- Dynamic typing (automatically cast integers et al)
npm i power-csvimport{csv2json}from'power-csv';constcsv='field;object.field;object.anotherField;object.numericField;array.0;array.1;array.2\r\nfoo;bar;foo;123;1;2;foo\r\nbar;;;456;3;4;bar';constjson=csv2json(csv);// [// {// field: 'foo',// object: {// field: 'bar',// anotherField: 'foo',// numericField: 123,// },// array: [1, 2, 'foo'],// },// {// field: 'bar',// object: {// field: '',// anotherField: '',// numericField: 456,// },// array: [3, 4, 'bar'],// },// ]import{csv2json}from'power-csv';constjson={foo: 'bar',bar: {foo: 'bar',},};constcsv=json2csv(json);// foo;bar.foo\r\nbar;barimportcsvfrom'power-csv';importexpressfrom'express';constapp=express();app.use(csv);app.get('/convert-to-csv',(req,res)=>{res.csv({foo: bar},'filename.csv');});MIT © Gowento