-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp.js
41 lines (35 loc) · 970 Bytes
/
temp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var csv = require("jquery-csv");
var fs = require("fs");
// const latestFileName = require("./latestFile");
var result = [];
function csvToObject(sample) {
console.log("Inside Object");
fs.readFile(sample, "UTF-8", (err, fileContent) => {
if (err) {
console.log(err);
}
result = csv.toArrays(fileContent, {}, (err, output) => {
if (err) {
console.log(err);
}
// else {
console.log(output);
// }
// return data;
// for (let i = 0, len = data.length; i < len; i++) {
// output.push(data[i]);
});
});
console.log("oupt===========================\n" + result);
}
// csvToObject();
function fetchArray() {
const sample = "./report.csv";
// console.log("await....");
// const data1 = await cto.csvToObject(sample);
// console.log("output data\n" + data1);
// csvToObject(sample);
console.log(csvToObject(sample));
}
fetchArray();
module.exports = { csvToObject };