Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kerollmops/csv2ndjson-lite
A little tool to convert a csv to a valid ndjson/json-stream (supports comma separated arrays)
https://github.com/kerollmops/csv2ndjson-lite
Last synced: 7 days ago
JSON representation
A little tool to convert a csv to a valid ndjson/json-stream (supports comma separated arrays)
- Host: GitHub
- URL: https://github.com/kerollmops/csv2ndjson-lite
- Owner: Kerollmops
- License: mit
- Created: 2020-12-12T11:05:01.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-05-30T10:03:27.000Z (over 3 years ago)
- Last Synced: 2024-10-12T17:56:05.889Z (about 1 month ago)
- Language: Rust
- Size: 11.7 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# csv2ndjson-lite
A little tool to convert a csv to a valid ndjson/json-stream (supported comma separated arrays).
## Installation
You can use cargo to install this tool:
```bash
cargo install -f csv2ndjson-lite
```## Usage
Here is an example CSV file, note that there is fields that are comma separated.
```csv
title,genres,scores,duration
Carmencita,"Documentary,Short","23,25,56",3.5
Miss Jerry,Romance,"3,2,6",5.3
Corbett and Courtney Before the Kinetograph,"Short,Sport","203,250,506",
```If you want to output an array when CSV values are comma separated, specify those headers as arguments.
```bash
cat mydata.csv | csv2ndjson-lite --arrays genres scores --numbers scores duration
```The output of the previous command would be something like so.
```json
{"title":"Carmencita","genres":["Documentary","Short"],"scores":[23,25,56],"duration":3.5}
{"title":"Miss Jerry","genres":["Romance"],"scores":[3,6],"duration":5.3}
{"title":"Corbett and Courtney Before the Kinetograph","genres":["Short","Sport"],"scores":[203,250]}
```