ITADN

bug/XLSX Table string representation loses row boundaries after 0.16.0 causing flattened output from partition_xlsx

#4235Openml-abdula 创建于 2026-02-11
bug
M
ml-abdulacommented
**Describe the bug** After upgrading `unstructured` from 0.16.0 to 0.16.1 and later, `partition_xlsx` returns a `Table` element whose string representation no longer preserves stable row boundaries. In 0.16.0, `str(Table)` allowed deterministic reconstruction of header and row groupings by splitting on double newlines. Starting in 0.16.1, the same XLSX file produces a flattened string where rows are no longer clearly separated, which breaks header to value reconstruction logic that previously worked reliably. This change appears related to the whitespace or HTML minification updates introduced around 0.16.1. **To Reproduce** Install two versions separately and run the same code against the same XLSX file. ```python from unstructured.partition.xlsx import partition_xlsx from unstructured.documents.elements import Table import io def inspect_xlsx(path): with open(path, "rb") as f: file_content = io.BytesIO(f.read()) elements = partition_xlsx(file=file_content) print("Element count:", len(elements)) for i, el in enumerate(elements): print("Type:", type(el)) if isinstance(el, Table): print("---- STRING OUTPUT START ----") print(str(el)) print("---- STRING OUTPUT END ----") inspect_xlsx("sample.xlsx") ``` Observed difference: 0.16.0 Row groupings are preserved in a way that allows: ```python rows = str(table).split("\n\n") ``` to produce logical rows. 0.16.1 and later `str(table)` appears flattened, producing a single continuous block such as: ``` 1 1 0 www.example.com 2 2 0 www.example2.com ... ``` Double newline row separation is no longer reliable. **Expected behavior** Either: 1. The string representation of `Table` for XLSX remains backward compatible and preserves stable row boundaries, or 2. A documented, stable API is provided to extract structured row and column data from the `Table` element without relying on whitespace formatting of `str(Table)`. The previous behavior allowed deterministic header extraction and key value reconstruction. That is no longer possible using the same logic. **Screenshots** If helpful, attach: • Output of `str(Table)` using 0.16.0 • Output of `str(Table)` using 0.16.1 or 0.16.10 Highlight that the row grouping changed. **Environment Info** Python version: 3.12 unstructured versions tested: 0.16.0 works as expected 0.16.1 fails to preserve row boundaries 0.16.10 exhibits same behavior as 0.16.1 OS: macOS Please let me know if additional environment details are required. **Additional context** Downstream logic depends on reconstructing header to value mappings for simple sheets by: 1. Treating first row as headers 2. Aligning subsequent rows positionally 3. Emitting Header colon Value formatted text This logic worked reliably until 0.16.0. If relying on `str(Table)` for row separation is not supported behavior, guidance on the correct structured extraction method for XLSX tables would be appreciated.
4 条评论