Skip to content

Commit c0d0e6b

Browse files
fix: Support HIAC Run Counter format in .xlsx files for Beckman PharmSpec parser (#1238)
## Summary - HIAC instruments can export the "Run Counter Test" format as `.xlsx`, not just `.xls` - The `_read_xlsx` method assumed all `.xlsx` files use the PharmSpec format (which has an `Approver_` footer marker), causing `AllotropeConversionError` on HIAC Run Counter `.xlsx` files - Added format detection: PharmSpec uses a 3-column header layout (`key` | `:` | `value`), while HIAC Run Counter uses a 2-column layout (`key` | `: value`). Routes to the existing `_parse_hiac_run_counter_format` handler when the file isn't PharmSpec. ## Test plan - [x] All 17 existing beckman_pharmspec tests pass (including the `missing_approver` error test) - [x] Verified the failing `.xlsx` HIAC file now parses successfully - [x] Verified existing `.xls` HIAC files still parse correctly - [x] Lint clean (ruff, black, mypy) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7b6f6fc commit c0d0e6b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/allotropy/parsers/beckman_pharmspec/beckman_pharmspec_reader.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ def __init__(self, named_file_contents: NamedFileContents) -> None:
2121
def _read_xlsx(self, named_file_contents: NamedFileContents) -> None:
2222
df = read_excel(named_file_contents.contents, header=None, engine="calamine")
2323

24+
# Detect format: PharmSpec uses col1=":" with value in col2,
25+
# HIAC Run Counter uses col1=": value" (colon+value merged).
26+
is_pharmspec = df[1].str.strip().eq(":").any() if 1 in df.columns else False
27+
if not is_pharmspec:
28+
self._parse_hiac_run_counter_format(df)
29+
return
30+
2431
"""
2532
Find the data in the raw dataframe. We identify the boundary of the data
2633
by finding the index first row which contains the word 'Particle' and ending right before

0 commit comments

Comments
 (0)