# csv2jsonic

> This module returns the CSV file in Json file or object.

Latest version **1.0.4** (published 2017-12-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install csv2jsonic
pnpm add csv2jsonic
yarn add csv2jsonic
bun add csv2jsonic
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2017-12-06 |
| First published | 2015-05-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+7 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jun Fujimura |
| Maintainers | sv.junic |
| Keywords | node.js, csv, json |

## Links

- npm: https://www.npmjs.com/package/csv2jsonic
- Repository: https://github.com/svjunic/csv2json
- Homepage: https://github.com/svjunic/csv2json#readme
- Issues: https://github.com/svjunic/csv2json/issues
- npm.io page: https://npm.io/package/csv2jsonic

## Dependencies (6)

- [fs](https://npm.io/package/fs.md) 0.0.2
- [csv](https://npm.io/package/csv.md) ^0.4.1
- [mocha](https://npm.io/package/mocha.md) ^2.2.5
- [lodash](https://npm.io/package/lodash.md) ^3.3.0
- [node-csv](https://npm.io/package/node-csv.md) ^0.1.2
- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.4.10

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.4 (latest) — 2017-12-06
- 1.0.3 — 2015-06-18
- 1.0.2 — 2015-06-08
- 1.0.1 — 2015-05-28
- 1.0.0 — 2015-05-22

## README

[![Build Status](https://travis-ci.org/svjunic/csv2jsonic.svg?branch=master)](https://travis-ci.org/svjunic/csv2jsonic)

# csv2jsonic
This module returns the CSV file in Json file or object.

## npm

```
npm install csv2jsonic
```

## example

```
// require
var csv2jsonic = require('csv2jsonic')();

// option setup
csv2jsonic.setup( { outputJsonPath: './test/json/parameter1.json' } );

return csv2jsonic.loadCSV( './test/csv/parameter2.csv' )
  .then( function ( data ) {
    // complete save json
    console.log( data );
    // [{"user":"sv.junic1","field1":"field1-1Value","field2":{"field2Child1":"field2-1Value","field2Child2":"field2-2Value"},"field3":{"field3Child":{"field3ChildChild":"100"}}}]
  });
```

## Method

### loadCSV
```
// require
var csv2jsonic = require('../csv2jsonic.js')();

// option setup
csv2jsonic.setup( { outputJsonPath: './test/json/parameter1.json' } );

return csv2jsonic.loadCSV( './test/csv/parameter2.csv' )
  .then( function ( data ) {
    // complete save json
    consone.log( data );
    // [{"user":"sv.junic1","field1":"field1-1Value","field2":{"field2Child1":"field2-1Value","field2Child2":"field2-2Value"},"field3":{"field3Child":{"field3ChildChild":"100"}}}]
  });
```

### convert
Convert an array of CSV format to the object of Json format.
```
var testdata = [
  [ "user","field1","field2:mogeta" ],
  [ "sv.junic1","field1Value","field2Value" ]
];
var csv2jsonic = require('../csv2jsonic.js')();
console.log( csv2jsonic.convert( array ) );
// => { user:"sv.junic1", field1:"field1Value", field2:{ mogeta: "field2Value" } }
```

##  setup option

### debug
Type: `Boolean`
Default: false

### charset
Type: `String`
Default: cp932 // shift_jis

Can be utf-8.

### pretty
Type: `Boolean`
Default: false

### delimitter
Type: `String`
Default: '|'

### outputJsonPath
Type: `String`
Default: ''


input
```
user,field1,field2:field2Child1,field2:field2Child2,field3:field3Child:field3ChildChild
sv.junic1,field1Value,field2-1Value,field2-2Value,100
sv.junic1,field1Value,field2-1Value,field2-2Value,100
```

output
```
[
    {
        "user": "sv.junic1",
        "field1": "field1Value",
        "field2": {
            "field2Child1": "field2-1Value",
            "field2Child2": "field2-2Value"
        },
        "field3": {
            "field3Child": {
                "field3ChildChild": "100"
            }
        }
    },
    {
        "user": "sv.junic1",
        "field1": "field1Value",
        "field2": {
            "field2Child1": "field2-1Value",
            "field2Child2": "field2-2Value"
        },
        "field3": {
            "field3Child": {
                "field3ChildChild": "100"
            }
        }
    }
]
```

---
_Source: https://npm.io/package/csv2jsonic · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
