-
Notifications
You must be signed in to change notification settings - Fork 0
/
ipl6.js
54 lines (45 loc) · 1.23 KB
/
ipl6.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
42
43
44
45
46
47
48
49
50
51
52
53
54
var fs = require('fs');
function extractingCSV(filePath) {
console.log(filePath);
var f = fs.readFileSync(filePath, {
encoding: 'utf-8'
});
f = f.split("\n");
// console.log(f);
headers = f.shift().split(",");
// console.log(headers);
var DATA = [];
//console.log(DATA);
f.forEach(function (d) {
tmp = {};
row = d.split(",");
//console.log(row);
for (var i = 0; i < headers.length; i++) {
tmp[headers[i]] = row[i];
}
DATA.push(tmp);
});
return DATA;
}
function TotalMatch(){
var matches=extractingCSV('./matches.csv');
// console.log(matches);
// var total = 0;
// matches.forEach( function(record) {
// total +=Number(record.id);
// });
// var total = matches.reduce( function(tot, record) {
// if (!tot.hasOwnProperty(record['id'])){
// tot[record["id"]]=1;
// return tot;
// }else{
// tot[record["id"]]=tot[record["id"]]+1;
// return tot;
// }
// },0);
// console.log(total);
// // var count = 0;
// for (var k in matches) if (matches.hasOwnProperty(k['id'])) ++count;
console.log(matches);
}
TotalMatch();