-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
35 lines (35 loc) · 1.02 KB
/
app.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
const csv = require('csv-parser');
const fs = require('fs');
var database = '[LEGAL]';
var list = {};
var output = "";
fs.createReadStream('list.csv')
.pipe(csv())
.on('data', (row) => {
const offender = row['Offending Value'];
const sid = row['Object Identifier'];
const doc = row['Object Name'];
if (typeof list[doc] === 'undefined') {
console.log('Adding ' + doc);
list[doc] = sid;
output = output + "DELETE FROM " + database + ".[MHGROUP].[DOC_NVPS] WHERE [SID] = " + sid + "; \r\n";
}
})
.on('end', () => {
fs.stat('queries.sql', function (err, stats) {
if (err) {
outputData();
}
fs.unlink('queries.sql', function (err) {
if (err) return console.log(err);
outputData();
});
});
});
function outputData() {
fs.appendFile('queries.sql', output, err => {
if (err) {
console.error(err);
}
});
}