Unstructured-IO / Unstructured-IO/unstructured
bug/XLSX Table string representation loses row boundaries after 0.16.0 causing flattened output from partition_xlsx
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 15.5k
- Forks
- 1.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 13
Description
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.
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:
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:
- The string representation of
Tablefor XLSX remains backward compatible and preserves stable row boundaries,
or
- A documented, stable API is provided to extract structured row and column data from the
Tableelement without relying on whitespace formatting ofstr(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:
- Treating first row as headers
- Aligning subsequent rows positionally
- 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the partition_xlsx entry point and the Table element behavior, then reproduce the same XLSX output on versions 0.16.0 and 0.16.1 or later. Trace the whitespace or HTML minification changes mentioned in the issue and verify that row boundaries are either preserved compatibly or that a stable structured extraction path is available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100