Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tonytonyjan/csv_to_json
A Command-Line Tool converting CSV to JSON
https://github.com/tonytonyjan/csv_to_json
csv json ruby
Last synced: about 2 months ago
JSON representation
A Command-Line Tool converting CSV to JSON
- Host: GitHub
- URL: https://github.com/tonytonyjan/csv_to_json
- Owner: tonytonyjan
- Created: 2020-01-20T08:17:39.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-20T08:17:56.000Z (almost 5 years ago)
- Last Synced: 2024-11-19T16:12:02.818Z (about 2 months ago)
- Topics: csv, json, ruby
- Language: Ruby
- Size: 1.95 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# csv_to_json
A command-line tool for converting CSV to JSON
## Installation
```
gem install csv_to_json
```## Usage
```
$ csv_to_json --help
Usage: csv_to_json [options] [FILE]
--headers=x,y,z
--converters=x,y,z
--[no-]stream
-h, --help Prints this help
```### Header Detectection
```
$ printf 'name,age,birth\nTony,18,1989-11-23\nJason,19,1919-12-13' |
csv_to_json | jq
[
{
"name": "Tony",
"age": "18",
"birth": "1989-11-23"
},
{
"name": "Jason",
"age": "19",
"birth": "1919-12-13"
}
]
```
### Custom Headers```
$ printf 'Tony,18,1989-11-23\nJason,19,1919-12-13' |
csv_to_json --headers name,age,birth | jq
[
{
"name": "Tony",
"age": "18",
"birth": "1989-11-23"
},
{
"name": "Jason",
"age": "19",
"birth": "1919-12-13"
}
]
```### Type Conversion
```
$ printf 'name,age,birth\nTony,18,1989-11-23\nJason,19,1919-12-13' |
csv_to_json --converters numeric | jq
[
{
"name": "Tony",
"age": 18,
"birth": "1989-11-23"
},
{
"name": "Jason",
"age": 19,
"birth": "1919-12-13"
}
]
```### Streaming
```
$ printf 'name,age,birth\nTony,18,1989-11-23\nJason,19,1919-12-13' |
csv_to_json --stream
{"name":"Tony","age":"18","birth":"1989-11-23"}
{"name":"Jason","age":"19","birth":"1919-12-13"}
```