@norvento/csv-generator
TypeScript icon, indicating that this package has built-in type declarations

2.2.0 • Public • Published

Norvento csv generator

Usage

  • Install the library: yarn install @norvento/csv-generator

  • Create the csv headers definition like this:

    const csvHeaders = [
        {id: "id1", title: "title1"},
        {id: "id2", title: "title2"},
        {id: "id3", title: "title3"},
    ]
    
  • Create the CSVGenerator instance and provide the csv headers and a locale. The locale is used to localize the numbers and dates:

    const csvGenerator = new CSVGenerator(csvHeaders, 'es-ES');
    
  • Call csvGenerator.generateCsv(content), where content is your raw data to be transformed to CSV. The raw data must have the following format:

    const content = [
        {
            id1: "value id1 row 1",
            id2: "value id2 row 1",
            id3: "value id3 row 1",
        },
        {
            id1: "value id1 row 2",
            id2: "value id2 row 2",
            id3: "value id3 row 2",
        },
        ...
    ]
    

    The csv is returned as a string.

Readme

Keywords

none

Package Sidebar

Install

npm i @norvento/csv-generator

Weekly Downloads

4

Version

2.2.0

License

ISC

Unpacked Size

17.9 kB

Total Files

17

Last publish

Collaborators

  • sorozco_norvento
  • yadrio_norvento
  • dcastro_norvento
  • norvento.ds
  • jmouriz_norvento