-
Notifications
You must be signed in to change notification settings - Fork 0
/
banks.js
70 lines (64 loc) · 1.98 KB
/
banks.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
var atms = require("./banks.json");
var fs = require("fs");
var csvWriter = require('csv-write-stream')
var result, id = 0;
var banks = ["Gotham", "Gringotts"];
var options = {
separator: '\t',
newline: '\n',
headers: undefined,
sendHeaders: true
},
writer = csvWriter(options);
result = atms.features.map(function(atm){
if (atm.properties["addr:city"] && atm.properties.name){
id++;
var name = atm.properties.name.match(/ING/) ? "ING" : banks[ id % 2];
console.log(atm.properties.name);
return {
mbranchid:
id,
mbankid:
name,
mline1:
atm.properties["addr:street"],
mline2:
atm.properties["addr:housenumber"],
mline3:
null,
mcity:
atm.properties["addr:city"],
mcounty:
null,
mstate:
null,
mcountrycode:
"PL",
mpostcode:
null,
mlocationlatitude:
atm.geometry.coordinates[1],
mlocationlongitude:
atm.geometry.coordinates[0],
mlicenseid:
atm.id,
mlicensename:
null,
mlobbyhours: null,
mdriveuphours: null,
mname:
name === "ING"? "ING Bank" : banks[ id % 2],
id:
id
};
};
return undefined;
})
.filter(function (atm){
return !!atm;
});
writer.pipe(fs.createWriteStream('out.csv'))
result.forEach(function (atm){
writer.write(atm);
});
writer.end();