-
Notifications
You must be signed in to change notification settings - Fork 0
/
check1.js
99 lines (69 loc) · 1.59 KB
/
check1.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
const csv=require('csvtojson')
const _ = require('lodash')
const q = require('q')
const csvFilePath='data-fixed.csv'
const csvFilePath2='data2.csv'
var data=[], data2=[];
var waits = [];
var dfd1 = q.defer();
waits.push(dfd1.promise);
csv()
.fromFile(csvFilePath)
.on('json',(jsonObj)=>{
// combine csv header row and csv line to a json object
// jsonObj.a ==> 1 or 4
data.push(jsonObj);
})
.on('done',(error)=>{
dfd1.resolve();
})
var dfd2 = q.defer();
waits.push(dfd2.promise);
csv()
.fromFile(csvFilePath2)
.on('json',(jsonObj)=>{
// combine csv header row and csv line to a json object
// jsonObj.a ==> 1 or 4
data2.push(jsonObj);
})
.on('done',(error)=>{
dfd2.resolve();
})
q.all(waits).then(checkResorts)
function checkResorts() {
try{
console.log("1");
var uniq1 = _.chain(data).map("name").uniq().value();
console.log("2");
var uniq2 = _.chain(data2).map("name").uniq().value();
console.log("3");
}
catch(e){
console.log(e);
}
console.log("4");
console.log(uniq1.length);
console.log(uniq2.length);
console.log(_.difference(uniq1, uniq2));
}
function lgC(){
console.log(data.length)
console.log(data2.length)
var c1 = _.chain(data).map("country").uniq().value(),
c2 = _.chain(data2).map("country").uniq().value();
var countries = {};
c1.forEach(function(c){
console.log(1);
if(countries[c])
countries[c].igluski = true
else
countries[c] = {igluski: true}
});
c2.forEach(function(c){
if(countries[c])
countries[c].skiclub = true
else
countries[c] = {skiclub: true}
});
console.log(countries);
}