Last active
May 26, 2023 15:26
-
-
Save kaosf/ec243d5b177fb40fc53b840c4d995000 to your computer and use it in GitHub Desktop.
WIP (Completed! → https://gist.github.com/kaosf/d91c7a0ec8379f3d46eb05091fc2f078)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const [keyword, type] = ["大空あかり", "キャラ"]; | |
// const [keyword, type] = ["穏やかじゃない", "セリフ"] | |
import * as fs from "fs"; | |
import * as path from "path"; | |
import { parse } from "csv-parse/sync"; | |
const source = path.join(__dirname, "aikatsup20230422.csv"); | |
const buffer = fs.readFileSync(source); | |
const rows = parse(buffer, { relax_column_count: true }) as string[][]; | |
let ids: string[] = []; | |
switch (type) { | |
case "キャラ": | |
ids = rows | |
.filter((row) => | |
row.slice(4, row.length).find((column) => column === keyword) | |
) | |
.map((row) => row[0]); | |
break; | |
case "セリフ": | |
const r = new RegExp(keyword); | |
ids = rows.filter((row) => r.test(row[1])).map((row) => row[0]); | |
break; | |
default: | |
process.exit(1); | |
} | |
console.log(ids); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment