Files
itinova-budget-si/scripts/diagnoseMasseSalarialeWorkbook.ts

21 lines
965 B
TypeScript

import XLSX from "xlsx";
const workbook = XLSX.readFile("/home/ubuntu/upload/TableaurecapMassesalarialeSANTINOVA-28.08.26.xlsx", { cellDates: true });
const sheet = workbook.Sheets["Masse salariale"];
if (!sheet) throw new Error("Feuille Masse salariale introuvable");
const rows = XLSX.utils.sheet_to_json<Array<unknown>>(sheet, { header: 1, raw: true, defval: null });
const candidates = rows.slice(5).filter((row) => row[1] !== null && row[1] !== undefined && row[1] !== "");
const typeCount = (index: number) => candidates.reduce<Record<string, number>>((counts, row) => {
const kind = row[index] === null ? "null" : row[index] instanceof Date ? "date" : typeof row[index];
counts[kind] = (counts[kind] ?? 0) + 1;
return counts;
}, {});
console.log(JSON.stringify({
candidates: candidates.length,
matriculeTypes: typeCount(1),
nomTypes: typeCount(2),
prenomTypes: typeCount(3),
posteTypes: typeCount(4),
dateEmbaucheTypes: typeCount(5),
}));