gts-x / scripts /read-knp.ts
JAMES HAN
feat: KNP terminology consistency check + AI translator credit detection
cad8df5
Raw
History Blame Contribute Delete
1.18 kB
import ExcelJS from "exceljs";
async function readKNP(path: string) {
const wb = new ExcelJS.Workbook();
await wb.xlsx.readFile(path);
console.log("=== " + path.split("/").pop() + " ===");
console.log("Sheets:", wb.worksheets.map((s) => s.name));
const sheet = wb.worksheets[0];
console.log("Rows:", sheet.rowCount, "Cols:", sheet.columnCount);
// Print header row
const header = sheet.getRow(1);
const cols: string[] = [];
header.eachCell({ includeEmpty: true }, (cell, colNum) => {
cols.push(colNum + ":" + String(cell.value || "").substring(0, 25));
});
console.log("Headers:", cols.join(" | "));
// Print rows 2-5
for (let r = 2; r <= Math.min(6, sheet.rowCount); r++) {
const row = sheet.getRow(r);
const vals: string[] = [];
for (let c = 1; c <= Math.min(15, sheet.columnCount); c++) {
vals.push(String(row.getCell(c).value || "").substring(0, 15));
}
console.log("Row " + r + ": " + vals.join(" | "));
}
console.log("");
}
async function main() {
await readKNP("/Users/jameshan/Downloads/Believer 2_KNP_AllLang.xlsx");
await readKNP("/Users/jameshan/Downloads/Crap Happens_KNP_AllLang.xlsx");
}
main();