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
+17
View File
@@ -87,6 +87,23 @@ class DetectColumnTypeTests(unittest.TestCase):
self.assertEqual(companies[0]["categories"]["software_engineering"], {"count": 8, "index": 110.0})
def test_parse_sheet_detects_company_column_with_token_header(self):
# Real-world salary sheets rarely use the bare token "Company";
# headers like "Company Name" / "Employer Name" must still be
# detected as the company column (previously silently skipped -> []).
for header in ("Company", "Company Name", "Employer Name"):
with self.subTest(header=header):
ws = FakeWorksheet([
(header, "Salary"),
("Example Corp", 105.5),
])
companies = parse_sheet(ws)
self.assertEqual(len(companies), 1)
self.assertEqual(companies[0]["company"], "Example Corp")
self.assertEqual(
companies[0]["categories"]["salary"], {"index": 105.5}
)
if __name__ == "__main__":
unittest.main()