forked from women-who-capstone/artemis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateDecFile.js
More file actions
31 lines (27 loc) · 975 Bytes
/
createDecFile.js
File metadata and controls
31 lines (27 loc) · 975 Bytes
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
const fs = require("fs");
const csv = require("fast-csv");
const path = require("path");
const init = async () => {
let descriptions = [];
var stream = await fs.createReadStream(path.join(__dirname, "podcasts.csv"));
const headers = [, , , , , , , , "Description"];
csv
.fromStream(stream, {headers})
.on("data", function(data) {
descriptions.push(data["Description"]);
})
.on("end", async function() {
var file = await fs.createWriteStream("descriptions.js");
file.on("error", function(err) {
console.log("error handle", err.message);
});
var file = await fs.createWriteStream("descriptions.js");
await file.on("error", function(err) {
console.log("error handle", err.message);
});
await file.write("let descriptions = [");
descriptions.forEach(async item => await file.write(`\`${item}\`, `));
await file.write("];\nmodule.exports = descriptions;");
});
};
init();