Repository navigation
Conversation
ExcelParser read each sheet with pandas' default NA handling, which turns a cell whose text is N/A, NA, NULL, None, NaN or n/a into a missing value. The row loop skips missing values, so the pair vanished: a patient with Allergies: None or a result marked N/A came out as if the cell were blank, and a header cell titled NA lost its label. The sheet is now read with keep_default_na=False. Blank cells arrive as an empty string, so the row loop skips those as well, and the dropna(how="all") pass is no longer needed: an empty row has no pairs and was already skipped by the same check. Error cells such as #N/A still read as missing.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ExcelParserreads each sheet withexcel_file.parse(sheet_name=…, header=None), which uses pandas' default NA handling. That turns a cell whose text isN/A,NA,NULL,None,NaN,n/aornaninto a missing value. The row loop skips missing values, so thecolumn: valuepair disappears from the chunk, as if the cell were blank. These strings usually are the answer.Noneunder "Allergies" means the patient has none,N/Ameans not applicable,NULLis what a database export writes, andNAis a region code. A header cell titledNAloses its label too, and falls back to the column letter.Measured with the locked docreader environment (pandas 2.3.3, openpyxl 3.1.5) and
xlsx_first_row_as_header=True, on a sheet with these cells:mainNone, RegionNA, ResultN/A, NoteokPatient: P1,Note: okPatient: P1,Allergies: None,Region: NA,Result: N/A,Note: okNULL, Note blankPatient: P2,Allergies: Penicillin,Region: EU…,Region: EU,Result: NULLn/a, RegionNaN, NotenanPatient: P3,Result: 42Patient: P3,Allergies: n/a,Region: NaN,Result: 42,Note: nanChanges in
docreader/parser/excel_parser.py:_read_sheet_dataframepasseskeep_default_na=False, so pandas keeps those strings as written.""instead ofNaN. The row loop now skips""as well as missing values, so a blank cell still adds no pair.df.dropna(how="all")pass is removed. With blanks as""it no longer matches anything, and an all-blank row has no pairs, so the loop's existingif not page_content: continuealready skips it. Row numbers insource_blocksare unchanged: they come from the index, which skipped rows keep.#N/Astill reads as missing, as before. pandas maps openpyxl error cells toNaNindependently ofna_values.Scope: this is the docreader path. Per
engines.go, xlsx goes to anydoc when the Go binary is built with it, so this parser runs with the builtin engine or when anydoc is not linked.Type of Change
Related Issue
None filed.
Testing
Three new cases in
docreader/tests/test_excel_parser.py(ExcelParserTest):test_cells_that_say_na_none_or_null_are_kept: the table above, in header mode. It fails onmain.test_a_header_cell_that_says_na_keeps_its_label: a headerNAstaysNA: 3. It fails onmain.test_blank_cells_and_blank_rows_are_still_skipped: a blank cell adds no pair, and an all-blank row adds no chunk. Itssource_blocksrow numbers stay[1, 2, 4]. This test passes onmaintoo; it pins that the change does not alter blank handling. It fails if the""check is dropped.It merges cleanly with the open #4160 (header labels) and #4447 (merge ranges), which touch nearby code.
Checklist
git diff --check origin/main...HEADpassesgolangci-lint run --new-from-rev=origin/main ./...)website-docs/, Swagger annotations, etc.)