New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@vanillaes/csv

Package Overview
Dependencies
Maintainers
0
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vanillaes/csv

A modern, fast, RFC 4180 compliant parser for JS

  • 3.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
0
Weekly downloads
 
Created
Source

CSV

CSV is a universal JavaScript CSV parser designed specifically to be simple, fast, and spec compliant.

GitHub Release NPM Release Bundlephobia Latest Status Release Status

Discord

Features

  • RFC Compliant
  • ECMAScript Module
  • Typescript Compatible

Imports

This package works isomorphically in browser and server-side JavaScript

Browser

Import directly from the local path or a CDN

<script type="module">
import { parse } from 'path/to/csv/index.js'
</script>

The minified version can be imported from

<script type="module">
import { parse } from 'path/to/csv/index.min.js'
</script>

Node

Install the package

npm install @vanillaes/csv

Import using the module path

import { parse } from '@vanillaes/csv'

Usage

CSV.parse()

Takes a string of CSV data and converts it to a 2 dimensional array of [entries][values]

Arguments

CSV.parse(csv, {options}, reviver(value, row, col)) : [entries][values]

  • csv - the CSV string to parse
  • options
    • typed - infer types (default false)
  • reviver1 - a custom function to modify the output (default (value) => value)

1 Values for row and col are 1-based.

Example
const csv = `
header1,header2,header3
aaa,bbb,ccc
zzz,yyy,xxx
`;
const parsed = parse(csv)
console.log(parsed);
> [
>   [ "header1", "header2", "header3" ],
>   [ "aaa", "bbb", "ccc" ],
>   [ "zzz", "yyy", "xxx" ]
> ]

CSV.stringify()

Takes a 2 dimensional array of [entries][values] and converts them to CSV

Arguments

CSV.stringify(array, {options}, replacer(value, row, col)) : string

  • array - the input array to stringify
  • options
    • eof - add a trailing newline at the end of file (default true)
  • replacer1 - a custom function to modify the values (default (value) => value)

1 Values for row and col are 1-based.

Example
const data = [
  [ "header1", "header2", "header3" ],
  [ "aaa", "bbb", "ccc" ],
  [ "zzz", "yyy", "xxx" ]
];
const stringified = stringify(data)
console.log(stringified);
> "header1,header2,header3"
> "aaa,bbb,ccc"
> "zzz,yyy,xxx"

Typescript

Typings are generated from JSDoc using Typescript. They are 100% compatible with VSCode Intellisense and will work seamlessly with Typescript.

Keywords

FAQs

Package last updated on 22 Aug 2024

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