Socket
Book a DemoInstallSign in
Socket

csv-into-json

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csv-into-json

A Synchronous CSV to JSON convertor package.

latest
npmnpm
Version
1.0.38
Version published
Maintainers
1
Created
Source

#csv-into-json

A Synchronous CSV to JSON convertor package.

const {csvPath} = require('csv-into-json')

let data = csvPath('./filename.csv')     // providing your file path

let jsonData = JSON.stringify(data)      // stringify returned data into JSON  
console.log(jsonData)

Or use it with express to send JSON response (Content-Type : application/json) as follows -

Express-Code

##Installation

$ npm install csv-into-json

##Usage

  • Parse your CSV-file data into JSON in two steps:
    • Provide relative path to your CSV file inside:   csvPath(" ./yourfilepath ") and store it inside a variable.
    • Convert the data stored inside that variable into JSON using JSON.stringify() function.

e.g :

  • CSV data :
Name,Age,Address in
Andy,21,Down town
Barbara,25,"Old street, 36"
Carl,24,Kings cross 
  • Output JSON :
[
    {
        "name": "Andy",
        "age": "21",
        "address-in": "Down town"
    },
    {
        "name": "Barbara",
        "age": "25",
        "address-in": "Old street, 36"
    },
    {
        "name": "Carl",
        "age": "24",
        "address-in": "Kings cross"
    }
]

Keywords

csv

FAQs

Package last updated on 24 Jul 2020

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