aboutsummaryrefslogtreecommitdiff
path: root/e621/csv2json.js
diff options
context:
space:
mode:
authorRaindropsSys <raindrops@equestria.dev>2024-06-13 15:46:03 +0200
committerRaindropsSys <raindrops@equestria.dev>2024-06-13 15:46:03 +0200
commite44e2fe070484e06d384a31ef2699c3a2d5d474e (patch)
tree2d5eb5d1b01646270d18cf1f2d94519966d6e7de /e621/csv2json.js
downloadfaunerie-e44e2fe070484e06d384a31ef2699c3a2d5d474e.tar.gz
faunerie-e44e2fe070484e06d384a31ef2699c3a2d5d474e.tar.bz2
faunerie-e44e2fe070484e06d384a31ef2699c3a2d5d474e.zip
GitHub migration
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));
+ });