/* ============================================================================= * spreadsheet_numfmt_survey_entry.ts (B 자기 시험) * 실무 구조도 xlsx 세 벌에서 뽑은 실제 숫자 형식 코드 전부를 numfmt 로 돌려 사람이 대조. * 입력 = 시험이 openpyxl 로 미리 뽑은 JSON(코드 · 실측 수 · 실측 글 견본). * ========================================================================== */ import { readFileSync } from "node:fs"; import { toFrac } from "@ui/sheet/ui_template_sheet_frac"; import { formatValue } from "../../../A00_Common/spreadsheet/spreadsheet_numfmt"; interface CodeSample { code: string; count: number; num: number | null; str: string | null; } const inputPath = process.argv[2]; const samples: CodeSample[] = JSON.parse(readFileSync(inputPath, "utf-8")); const rows = samples.map((s) => { let numOut: string | null = null; let numErr: string | null = null; if (s.num !== null) { try { numOut = formatValue(toFrac(s.num), s.code).글; } catch (e) { numErr = String(e); } } let strOut: string | null = null; let strErr: string | null = null; if (s.str !== null) { try { strOut = formatValue(s.str, s.code).글; } catch (e) { strErr = String(e); } } return { ...s, numOut, numErr, strOut, strErr }; }); console.log(JSON.stringify(rows, null, 1));