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