Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

export-to-csv-fix-source-map

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

export-to-csv-fix-source-map

Easily create CSV data from json collection

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.6K
increased by3.06%
Maintainers
1
Weekly downloads
 
Created
Source

export-to-csv | Export to CSV Mini Library

Based off of this library by Javier Telio

Helper library to quickly and easily create a CSV file in browser or Node

Installation

yarn add export-to-csv
// npm install --save export-to-csv

Usage


import { ExportToCsv } from 'export-to-csv';

var data = [
  {
    name: 'Test 1',
    age: 13,
    average: 8.2,
    approved: true,
    description: "using 'Content here, content here' "
  },
  {
    name: 'Test 2',
    age: 11,
    average: 8.2,
    approved: true,
    description: "using 'Content here, content here' "
  },
  {
    name: 'Test 4',
    age: 10,
    average: 8.2,
    approved: true,
    description: "using 'Content here, content here' "
  },
];

  const options = { 
    fieldSeparator: ',',
    quoteStrings: '"',
    decimalSeparator: '.',
    showLabels: true, 
    showTitle: true,
    title: 'My Awesome CSV',
    useTextFile: false,
    useBom: true,
    useKeysAsHeaders: true,
    // headers: ['Column 1', 'Column 2', etc...] <-- Won't work with useKeysAsHeaders present!
  };

const csvExporter = new ExportToCsv(options);

csvExporter.generateCsv(data);

API

OptionDefaultDescription
fieldSeparator,Defines the field separator character
filename'generated'Sets the name of the downloaded file. ".csv" will be appended to the value provided.
quoteStrings"If provided, will use this characters to "escape" fields, otherwise will use double quotes as deafult
decimalSeparator.Defines the decimal separator character (default is .). If set to "locale", it uses the language sensitive representation of the number.
showLabelsfalseIf true, the first row will be the headers option or object keys if useKeysAsHeaders is present
showTitlefalseIncludes the title as the first line in the generated file
title'My Generated Report'This string will be used as the report title
useBomtrueIf true, adds a BOM character at the start of the CSV to improve file compatibility
useTextFilefalseIf true, returns a .txt file instead of .csv
useKeysAsHeadersfalseIf true, this will use the keys of the first object in the collection as the column headers
headers[]Expects an array of strings, which if supplied, will be used as the column headers

Thanks!

Credits and Original Authors
javiertelioz
sn123
arf1980

Keywords

FAQs

Package last updated on 17 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc