-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse-async.js
More file actions
39 lines (36 loc) · 1.22 KB
/
parse-async.js
File metadata and controls
39 lines (36 loc) · 1.22 KB
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
// Please use async lib https://github.com/caolan/async
var fs = require('fs');
var parse = require('csv-parse');
var async = require('async');
var helper = require('./helper');
var debug = require('debug')('hello');
var inputFile='sample.csv';
var parser = parse({delimiter: ','}, function (err, data) {
async.eachSeries(data, function (line, callback) {
Object.keys(data).forEach(function (key) {
if(key!=0)
{
var full_name = data[key][0]+' '+data[key][1];
helper.sendSms(full_name, function afterSending(err, sendingStatus) {
var nameToLog;
if (err) {
debug(err.message);
nameToLog = {
sendingStatus,
full_name
};
}
if (nameToLog) {
helper.logToS3(nameToLog, function afterLogging(err, loggingStatus) {
if (err) {
debug(err.message);
}
// console.log(loggingStatus);
});
}
});
}
});
});
})
fs.createReadStream(inputFile).pipe(parser);