From e44e2fe070484e06d384a31ef2699c3a2d5d474e Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Thu, 13 Jun 2024 15:46:03 +0200 Subject: GitHub migration --- e621/csv2json.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 e621/csv2json.js (limited to 'e621/csv2json.js') diff --git a/e621/csv2json.js b/e621/csv2json.js new file mode 100755 index 0000000..ee55fdb --- /dev/null +++ b/e621/csv2json.js @@ -0,0 +1,34 @@ +const { parse } = require("csv-parse"); +const fs = require('fs'); + +let tags = []; +let aliases = []; + +fs.createReadStream("./tags.csv") + .pipe(parse({ delimiter: ",", from_line: 2 })) + .on("data", (row) => { + tags.push({ + id: parseInt(row[0]), + name: row[1], + category: parseInt(row[2]), + postCount: parseInt(row[3]) + }); + }) + .on("end", () => { + fs.writeFileSync("./tags.json", JSON.stringify(tags)); + }); + +fs.createReadStream("./tag_aliases.csv") + .pipe(parse({ delimiter: ",", from_line: 2 })) + .on("data", (row) => { + aliases.push({ + id: parseInt(row[0]), + antecedentName: row[1], + consequentName: row[2], + createdAt: new Date(row[3]), + status: row[4] + }); + }) + .on("end", () => { + fs.writeFileSync("./tag_aliases.json", JSON.stringify(aliases)); + }); -- cgit