forked from pmcdowell-okta/okta2anything
-
Notifications
You must be signed in to change notification settings - Fork 0
/
csv.js
32 lines (25 loc) · 748 Bytes
/
csv.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
var fs = require('fs');
var parse = require('csv-parse');
var userName = process.argv[2];
var password = process.argv[3];
var csvData=[];
fs.createReadStream("users.csv")
.pipe(parse({delimiter: ','}))
.on('data', function(csvrow) {
// console.log(csvrow);
//do something with csvrow
csvData.push(csvrow);
})
.on('end',function() {
var DudeFoundMyCarAndUser=0;
for (var item of csvData) {
if (item[0]==userName && item[1]==password) {
DudeFoundMyCarAndUser=1
}
}
if (DudeFoundMyCarAndUser!=0) {
console.log('{"Active":"true"}')
} else {
console.log('{"Active":"false"}')
}
});