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

csvtojson

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csvtojson

A tool concentrating on converting csv data to JSON with customised parser supporting

  • 2.0.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
862K
increased by4.21%
Maintainers
1
Weekly downloads
 
Created

What is csvtojson?

The csvtojson npm package is a powerful and flexible library for converting CSV data to JSON format. It supports a wide range of features including streaming, custom parsing, and handling of various CSV formats.

What are csvtojson's main functionalities?

Basic CSV to JSON Conversion

This feature allows you to convert a CSV file to a JSON object. The code reads a CSV file from the specified path and converts it to JSON.

const csv = require('csvtojson');

csv()
  .fromFile('path/to/your/file.csv')
  .then((jsonObj) => {
    console.log(jsonObj);
  });

Streaming CSV to JSON

This feature allows you to stream CSV data and convert it to JSON on the fly. It is useful for handling large CSV files without loading the entire file into memory.

const csv = require('csvtojson');
const fs = require('fs');

const readStream = fs.createReadStream('path/to/your/file.csv');
const writeStream = fs.createWriteStream('path/to/your/output.json');

readStream.pipe(csv()).pipe(writeStream);

Custom Parsing

This feature allows you to customize the parsing process, such as specifying custom headers for CSV files that do not have a header row.

const csv = require('csvtojson');

csv({
  noheader: true,
  headers: ['header1', 'header2', 'header3']
})
  .fromFile('path/to/your/file.csv')
  .then((jsonObj) => {
    console.log(jsonObj);
  });

Handling Different Delimiters

This feature allows you to handle CSV files with different delimiters, such as semicolons instead of commas.

const csv = require('csvtojson');

csv({
  delimiter: ';'
})
  .fromFile('path/to/your/file.csv')
  .then((jsonObj) => {
    console.log(jsonObj);
  });

Other packages similar to csvtojson

Keywords

FAQs

Package last updated on 26 Jun 2019

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