Skip to content

Commit fa8f1f5

Browse files
committed
1.3.2
Experimental support for big CSVs... (toCSV)
1 parent 36e2d8f commit fa8f1f5

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

inout

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ var
44
JSONstat=require("jsonstat-toolkit"),
55

66
dataset=function(contents){
7+
var json;
8+
79
try{
8-
var json=JSON.parse(contents);
10+
json=JSON.parse(contents);
911
}catch (e){
1012
console.error("Error: The input does not containt JSON.");
1113
process.exit(1);
@@ -66,9 +68,16 @@ var
6668
console.log("Warning: Using " + output + " instead.");
6769
}
6870

69-
if(fs.writeFileSync(output, content, "utf8")===false){
70-
console.error("Error: Couldn't create " + output + ".");
71-
process.exit(1);
71+
//So far, only in the non-stream interface...
72+
if(Array.isArray(content)){
73+
content.forEach(function(item){
74+
fs.writeFileSync(output, item+"\n", { flag: "a+" });
75+
});
76+
}else{
77+
if(fs.writeFileSync(output, content, "utf8")===false){
78+
console.error("Error: Couldn't create " + output + ".");
79+
process.exit(1);
80+
}
7281
}
7382

7483
console.log("Success: " + output + " has been created.");

jsonstat2csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var
3939
csv=utils.toCSV(
4040
inout.dataset(contents),
4141
{
42+
array: argv.stream ? false : true, //big datasets experimentally when interface is not stream (weird)
4243
rich: argv.rich,
4344
status: argv.status,
4445
vlabel: argv.vlabel,

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsonstat-conv",
3-
"version": "1.3.1",
3+
"version": "1.3.2",
44
"description": "JSON-stat Command Line Conversion Tools",
55
"homepage": "https://github.com/jsonstat/conv",
66
"keywords": [
@@ -39,7 +39,7 @@
3939
},
4040
"license": "Apache-2.0",
4141
"dependencies": {
42-
"jsonstat-suite": "^3.1.7",
42+
"jsonstat-suite": "^3.2.2",
4343
"jsonstat-toolkit": "^1.3.1",
4444
"rw": "^1.3.3",
4545
"yargs": "^15.1.0"

0 commit comments

Comments
 (0)