-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfiler.cjs
39 lines (33 loc) · 893 Bytes
/
filer.cjs
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
const lineByLine = require("n-readlines");
const liner = new lineByLine("WaitingList.csv");
const fs = require("fs");
const path = require("path");
const { cwd } = require("process");
let line;
let lineNumber = 0;
const fileContents = [];
while ((line = liner.next())) {
if (lineNumber === 0 || lineNumber > 5) {
if (line.toString().trim() !== ",") {
if (
line.toString().charAt(1) !== "A" &&
line.toString().charAt(1) !== "AB"
) {
const liney = line.toString();
fileContents.push(liney);
}
}
}
lineNumber++;
}
console.log("end of file reached");
console.log(fileContents.join("\n"));
const file = path.join(cwd(), "ModifiedWaitingList.csv");
console.log(file);
fs.writeFile(file, fileContents.join("\n"), (err) => {
if (err) {
console.error(err);
} else {
console.log("Created new file successfully");
}
});