converter-csvtojson-cli

0.0.6 • Public • Published

A Customized CSV to Json Converter CLI

Based on https://github.com/Keyang/node-csvtojson

Input csv

    id,bool_data,date,*|array*catagories|,*:array*catagories:,*|jsonarray*employee.catagories,*json*employee.name,*json*employee.age,*json*employee.number,*array*address,*array*address,*jsonarray*employee.key,*jsonarray*employee.key,*omit*id
    1,true,2012-02-12,a|b|c|f,"a:b:c:f",a|b|c|f,Eric,31,51234,Dunno Street,Kilkeny Road,key1,key2,2
    1,false,2012-03-06,a|b|c|,"a:b:c:","a|b|c",Ted,28,51289,"21, Cambridge Road",Tormore,key3,key4,4

Output json

	[{
        "id": 1,
        "bool_data": true,
        "date": "2012-02-12",
        "catagories|": ["a", "b", "c", "f"],
        "catagories:": ["a", "b", "c", "f"],
        "employee": {
            "catagories": ["a", "b", "c", "f"],
            "name": "Eric",
            "age": 31,
            "number": 51234,
            "key": ["key1", "key2"]
        },
        "address": ["Dunno Street", "Kilkeny Road"]
    }, {
        "id": 1,
        "bool_data": false,
        "date": "2012-03-06",
        "catagories|": ["a", "b", "c", ""],
        "catagories:": ["a", "b", "c", ""],
        "employee": {
            "catagories": ["a", "b", "c"],
            "name": "Ted",
            "age": 28,
            "number": 51289,
            "key": ["key3", "key4"]
        },
        "address": ["21, Cambridge Road", "Tormore"]
    }]

Added Parser Types

  1. *|array* : parser a|b|c|d into [a,b,c,d], i.e: *|array*catagories
  2. *|jsonarray* : parser a|b|c|d into [a,b,c,d],i.e: *|jsonarray*my.catagories
  3. *:array* : parser a🅱️c:d into [a,b,c,d], i.e: *:array*catagories
  4. *:jsonarray* : parser a🅱️c:d into [a,b,c,d],i.e: *:jsonarray*my.catagories

usage

csv2json test.csv > converted.json
cat test.csv  | csv2json > converted.json

Readme

Keywords

none

Package Sidebar

Install

npm i converter-csvtojson-cli

Weekly Downloads

1

Version

0.0.6

License

none

Last publish

Collaborators

  • leoh