From 9df1fb2a5ad011fc8a4d436e6e8296a3b853b43e Mon Sep 17 00:00:00 2001 From: Karl Date: Sat, 26 Aug 2017 17:31:22 +0200 Subject: [PATCH] move scripts to own folder --- scripts/buildTheJSON.js | 41 +++++++++++++++++++ {csv2json => scripts/csv2json}/Readme.md | 0 {csv2json => scripts/csv2json}/index.js | 0 {csv2json => scripts/csv2json}/package.json | 0 .../csv2json}/sampleMahlowat.json | 0 5 files changed, 41 insertions(+) create mode 100644 scripts/buildTheJSON.js rename {csv2json => scripts/csv2json}/Readme.md (100%) rename {csv2json => scripts/csv2json}/index.js (100%) rename {csv2json => scripts/csv2json}/package.json (100%) rename {csv2json => scripts/csv2json}/sampleMahlowat.json (100%) diff --git a/scripts/buildTheJSON.js b/scripts/buildTheJSON.js new file mode 100644 index 0000000..c8626df --- /dev/null +++ b/scripts/buildTheJSON.js @@ -0,0 +1,41 @@ +var fs = require('fs'); + +var dataJSON = require('./data.json'); +var thesesLst = [], listsLst = [], answersLst = []; + +for(var i=0; i < Object.keys(dataJSON.theses).length; i++) { + if (i !== 7 && i !== 8 && i !== 13) { + thesesLst.push(dataJSON.theses[i]); + } +} + +for(var i=0; i < Object.keys(dataJSON.lists).length; i++) { + listsLst.push(dataJSON.lists[i]); +} + +for(var i=0; i < Object.keys(dataJSON.answers).length; i++) { + answersLst.push(dataJSON.answers[i]); + + var templistAnswers = []; + for(var j=0; j < Object.keys(dataJSON.answers[i]).length; j++) { + if (j !== 7 && j !== 8 && j !== 13) { + templistAnswers.push(dataJSON.answers[i][j]); + } + } + answersLst[i] = templistAnswers; +} + +console.log(thesesLst, thesesLst.length); +//console.log(listsLst); +//console.log(answersLst); +dataJSON.lists = listsLst; +dataJSON.theses = thesesLst; +dataJSON.answers = answersLst; + +fs.writeFile("./generated.json", JSON.stringify(dataJSON, null, 4), function(err) { + if(err) { + return console.log(err); + } + + console.log("The file was saved!"); +}); diff --git a/csv2json/Readme.md b/scripts/csv2json/Readme.md similarity index 100% rename from csv2json/Readme.md rename to scripts/csv2json/Readme.md diff --git a/csv2json/index.js b/scripts/csv2json/index.js similarity index 100% rename from csv2json/index.js rename to scripts/csv2json/index.js diff --git a/csv2json/package.json b/scripts/csv2json/package.json similarity index 100% rename from csv2json/package.json rename to scripts/csv2json/package.json diff --git a/csv2json/sampleMahlowat.json b/scripts/csv2json/sampleMahlowat.json similarity index 100% rename from csv2json/sampleMahlowat.json rename to scripts/csv2json/sampleMahlowat.json