From 13dd4b62c2516506f94c049f11acb1e535ee12f9 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Wed, 25 Feb 2026 14:22:58 +0100 Subject: [PATCH] fix(parser): add alphanumeric sanitizer to excel header mapping to support characters like % and parenthesis --- services/dataProcessor.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/dataProcessor.ts b/services/dataProcessor.ts index 1c9b84a..c8e3da5 100644 --- a/services/dataProcessor.ts +++ b/services/dataProcessor.ts @@ -239,12 +239,16 @@ const normalizeMonth = (rawMonth: string): string => { const getColumnValue = (row: any, aliases: string[]): string => { const rowKeys = Object.keys(row); const normalizedRowKeys: Record = {}; + rowKeys.forEach(k => { - normalizedRowKeys[k.trim().toLowerCase()] = k; + // Normalize by removing all non-alphanumeric characters for a bulletproof exact match + // e.g., "ACOS %" -> "acos", "Sales (30d)" -> "sales30d" + const cleanKey = k.toLowerCase().replace(/[^a-z0-9]/g, ''); + normalizedRowKeys[cleanKey] = k; }); for (const alias of aliases) { - const lookup = alias.trim().toLowerCase(); + const lookup = alias.toLowerCase().replace(/[^a-z0-9]/g, ''); if (normalizedRowKeys[lookup]) { const actualKey = normalizedRowKeys[lookup]; const val = row[actualKey];