Created
May 31, 2017 22:25
-
-
Save dcarroll/f106c43c21c36d0411c13bda5c1ec317 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let fund = require("./data/dreaminvest-data-fund.json"); | |
let plan = require("./data/dreaminvest-data-plan.json"); | |
let records = fund.records; | |
let i,j,temparray = [],chunk = 200; | |
let fname = `data/dreaminvest-data-fund${i}d.json`; | |
let writeFile = function(name, contents) { | |
var fs = require('fs'); | |
fs.writeFile(name, contents, function(err) { | |
if(err) { | |
return console.log(err); | |
} | |
console.log("The file was saved!"); | |
}); | |
} | |
let writeDataFile = function(recordData) { | |
writeFile("data/" + recordData.fileName, JSON.stringify(recordData.data)); | |
temparray.push(recordData.fileName); | |
} | |
for (i=0,j=records.length; i<j; i+=chunk) { | |
writeDataFile( | |
{ "data": | |
{ "records":records.slice(i,i+chunk) }, | |
"fileName": `dreaminvest-data-fund${i}.json` | |
} | |
); | |
} | |
plan[1].files = temparray; | |
writeFile("data/dreaminvest-data-plan.json", JSON.stringify(plan)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment