Commit 5ed457bb authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent b25bcc71
...@@ -15,22 +15,32 @@ async function run() { ...@@ -15,22 +15,32 @@ async function run() {
arr.push(csv.parse(files[i], configs.data)) arr.push(csv.parse(files[i], configs.data))
arr = await Promise.all(arr) arr = await Promise.all(arr)
let count = 0
let arr2 = [] let arr2 = []
let arr3 = []
for (let i = 0; i < arr.length; i++) { for (let i = 0; i < arr.length; i++) {
let inline = arr[i] let inline = arr[i]
for (let j = 0; j < inline.length; j++) for (let j = 0; j < inline.length; j++) {
arr2.push(inline[j]) arr2.push(inline[j])
count++
}
} }
console.log(arr2) // console.log(arr2)
arr2 = _.orderBy(arr2, [configs.sort], ['asc']); arr2 = _.orderBy(arr2, [configs.sort], ['asc']);
for (let i = 0; i < 200; i++)
arr3.push(arr2[i])
// for (let i=0;i<files.length;i++) // for (let i=0;i<files.length;i++)
createfile(JSON.stringify(arr2, null, 2)) createfile(JSON.stringify(arr2, null, 2))
createfile2(JSON.stringify(arr3, null, 2))
console.log('Done') console.log('Done')
// process.exit(0) // process.exit(0)
// console.log(d) // console.log(d)
} }
...@@ -44,6 +54,16 @@ function createfile(data) { ...@@ -44,6 +54,16 @@ function createfile(data) {
} }
function createfile2(data) {
return new Promise(function (resolve, reject) {
fs.writeFile('work/result2.json', data, 'utf8', function (err) {
if (err) reject(err);
else resolve(data);
});
});
}
async function test2() { async function test2() {
let configs = await fs.readFileSync('./configTemp.json', 'utf8') let configs = await fs.readFileSync('./configTemp.json', 'utf8')
configs = JSON.parse(configs) configs = JSON.parse(configs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment