aboutsummaryrefslogtreecommitdiff
path: root/e621/csv2json.js
diff options
context:
space:
mode:
Diffstat (limited to 'e621/csv2json.js')
-rwxr-xr-xe621/csv2json.js34
1 files changed, 34 insertions, 0 deletions
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));
+ });