-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
39 lines (32 loc) · 997 Bytes
/
index.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
var csv = require('csv');
var path = require('path');
var fs = require('graceful-fs');
var directory = path.join(__dirname, 'osm-landmarks/');
function getRows(file, callback) {
csv.parse(fs.readFileSync(file), function (error, rows) {
if (error) callback(error, []);
return callback(null, rows.slice(1, rows.length));
});
}
function getLakes(callback) {
var file = path.join(directory, 'lakes.csv');
return getRows(file, callback);
}
function getAirports(callback) {
var file = path.join(directory, 'airports.csv');
return getRows(file, callback);
}
function getRestaurants(callback) {
var file = path.join(directory, 'restaurants.csv');
return getRows(file, callback);
}
function getPopular(callback) {
var file = path.join(directory, 'popular.csv');
return getRows(file, callback);
}
module.exports = {
'getLakes': getLakes,
'getAirports': getAirports,
'getRestaurants': getRestaurants,
'getPopular': getPopular
};