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.

npmnpm
Version
1.0.33
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

#csv-into-json

A Synchronous CSV to JSON convertor package.

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

csvPath('./filename.csv')       

getJson = (data) => {
    let jsonData = JSON.stringify(data)
    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 ").
    • Create a getJson() function and pass any argument inside it which would be the returned JSON data.

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 20 Jun 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