Socket
Book a DemoInstallSign in
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

latest
Source
npmnpm
Version
2.0.10
Version published
Weekly downloads
866K
3.77%
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

csv

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.