easy-json2csv
TypeScript icon, indicating that this package has built-in type declarations

2.0.4 • Public • Published

easy-json2csv

Transform JSON into CSV file or stream

Installing

Install with npm or yarn

  npm install easy-json2csv
    or
  yarn add easy-json2csv

Getting Started

import { CSV }  from "easy-json2csv";

const csv = new CSV();

const header = [
  { columnName: "lines", refersTo: "somePropertyName"}]

const body = [
  { somePropertyName: "line 1" },
  { somePropertyName: "line 2" },
  { somePropertyName: "line 3" },
];

If you want a file

csv 
    .setHeader(header)
    .setBody(body)
    .setEncoding("utf8") //optional
    .write();
    

/* outputs a file containing:

displayName line 1; line 2; line 3; */

If you want a stream

var myCsvStream = csv 
    .setHeader(header)
    .setBody(body)
    .writeAsStream({ encoding: "utf8", hasSpecialChars: true});



Package Sidebar

Install

npm i easy-json2csv

Weekly Downloads

2

Version

2.0.4

License

ISC

Unpacked Size

12.5 kB

Total Files

13

Last publish

Collaborators

  • juliocesarlab