converter-csvtojson-cli
v0.0.6
Published
A customized commandline tools to convert csv to json based on csvtojson
Downloads
5
Readme
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
- *|array* : parser a|b|c|d into [a,b,c,d], i.e: *|array*catagories
- *|jsonarray* : parser a|b|c|d into [a,b,c,d],i.e: *|jsonarray*my.catagories
- *:array* : parser a:b:c:d into [a,b,c,d], i.e: *:array*catagories
- *:jsonarray* : parser a:b:c:d into [a,b,c,d],i.e: *:jsonarray*my.catagories
#usage
csv2json test.csv > converted.json
cat test.csv | csv2json > converted.json