fix(salary): detect company column from header token, not exact match (#151)

convert_salary_excel.py detected the company column via exact membership
in COMPANY_PATTERNS, so common real-world headers like "Company Name" or
"Employer Name" were never matched. parse_sheet then returned [] for that
sheet, silently dropping it from salary_data.json (or exiting with no
output for a single-sheet file).

Route company-column detection through the existing header_matches()
token matcher (already used for count/index detection). This only adds
detections; inputs that already worked (bare "Company"/"Firma"/...) are
unaffected.

Adds a regression test in tests/test_convert_salary_excel.py that fails
on master (returns []) and passes after the fix.
This commit is contained in:
Alaa-Taieb
2026-07-14 14:35:45 +02:00
committed by GitHub
parent 0a8fc194e5
commit 4128ca0318
2 changed files with 19 additions and 2 deletions
+2 -2
View File
@@ -91,7 +91,7 @@ def parse_sheet(ws, sheet_label=None):
header_row = None
for row_idx, row in enumerate(ws.iter_rows(min_row=1, max_row=10, values_only=False), start=1):
for cell in row:
if cell.value and str(cell.value).strip().lower() in COMPANY_PATTERNS:
if cell.value and header_matches(str(cell.value), COMPANY_PATTERNS):
header_row = row_idx
break
if header_row:
@@ -111,7 +111,7 @@ def parse_sheet(ws, sheet_label=None):
city_col = None
for i, h in enumerate(headers):
h_lower = h.lower()
if h_lower in COMPANY_PATTERNS:
if header_matches(h, COMPANY_PATTERNS):
company_col = i
elif h_lower in CITY_PATTERNS:
city_col = i