Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nishant-jain-94/merge-convert-csv-to-json
Merges all the csv files and converts it to json
https://github.com/nishant-jain-94/merge-convert-csv-to-json
Last synced: 5 days ago
JSON representation
Merges all the csv files and converts it to json
- Host: GitHub
- URL: https://github.com/nishant-jain-94/merge-convert-csv-to-json
- Owner: nishant-jain-94
- License: mit
- Created: 2019-11-07T09:11:16.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T12:56:02.000Z (almost 2 years ago)
- Last Synced: 2024-09-17T01:15:20.460Z (about 2 months ago)
- Language: JavaScript
- Size: 1.22 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/nishant-jain-94/merge-convert-csv-to-json.svg?branch=master)](https://travis-ci.org/nishant-jain-94/merge-convert-csv-to-json) [![Coverage Status](https://coveralls.io/repos/github/nishant-jain-94/merge-convert-csv-to-json/badge.svg?branch=master)](https://coveralls.io/github/nishant-jain-94/merge-convert-csv-to-json?branch=master)
# merge-convert-csv-to-json
Merges all the csv files and converts it to json.
## :rocket: Features
- Merge all the `CSV` files and convert into single `JSON` file.
- Merge all the `CSV` files, convert it to `JSON` object, assign it to a `JSON field` an then store it in a `JSON` file.
- Merge all the `CSV` files, convert it to `JSON` with every object *keyedBy* a `JSON` field and then store it to a `JSON` file.
- Merge all the `CSV` files, convert it to `JSON` with every object *keyedBy* a `JSON` field, assign the object to a `JSON` field and then store it to a `JSON` file.
- Merge all the `CSV` files, convert into single `JSON` file by converting string values into map by providing `keyValueSplitter`, `propertySplitter`, `keyIndex`, `valueIndex`, `field` and `pluginType` as `transfromPropertyToMap`## Installation
#### Using NPM
```
npm install -g merge-convert-csv-to-json
```#### Using YARN
```
yarn add merge-convert-csv-to-json
```## Options
```
--pattern pattern The pattern of the input files to process.
--keyBy propertyName The name of the property to keyby.
--assignTo propertyName The name of the property to assign the result to.
--outputTo filePath The filepath to output the result to.
```## Usage
- Merge all the `CSV` files and convert into single `JSON` file.
```
merge-convert --pattern "/users/*.users.csv" --outputTo /users/merged.users.json
```
- Merge all the `CSV` files, convert it to `JSON` object, assign it to a `JSON field` and then store it in a `JSON` file.
```
merge-convert --pattern "/users/*.users.csv" --assignTo users --outputTo /users/merged.users.json
```
- Merge all the `CSV` files, convert it to `JSON` with every object *keyedBy* a `JSON` field and then store it to a `JSON` file.
```
merge-convert --pattern "/users/*.users.csv" --keyBy email --outputTo /users/merged.users.json
```
- Merge all the `CSV` files, convert it to `JSON` with every object *keyedBy* a `JSON` field, assign the object to a `JSON` field and then store it to a `JSON` file.
```
merge-convert --pattern "/users/*.users.csv" --keyBy email --assignTo users --outputTo /users/merged.users.json
```
- Merge all the `CSV` files, convert into single `JSON` file by converting string values into map by providing `keyValueSplitter`, `propertySplitter`, `keyIndex`, `valueIndex`, `field` and `pluginType` as `transfromPropertyToMap`
```json
# transformer-config.json
[
{
pluginType: "transformPropertyToMap",
keyValueSplitter: ":",
propertySplitter: ",",
keyIndex: "0",
valueIndex: "1",
field: "groups_access"
},
{
pluginType: "transformPropertyToMap",
keyValueSplitter: ":",
propertySplitter: ",",
keyIndex: "0",
valueIndex: "1",
field: "project_access"
}
]
``````
merge-convert --pattern "/users/*.users.csv" --outputTo /users/merged.users.json --transformerConfig transformer-config.json
```