Skip to content

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

Open

Description

@ml-abdula

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:

  1. The string representation of Table for XLSX remains backward compatible and preserves stable row boundaries,

or

  1. 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.

Activity

  1. added
    bug
    on Feb 11, 2026
  2. changed the title [-]bug/<short-name>[/-] [+]bug/XLSX Table string representation loses row boundaries after 0.16.0 causing flattened output from partition_xlsx[/+] on Feb 11, 2026
  3. ai-mountain commented on Feb 27, 2026

    @ai-mountain

    Hi, maintainers.
    I’m interested in contributing to this issue. As a new contributor, I’d appreciate your confirmation before starting.

  4. onefixoneline commented on Mar 8, 2026

    @onefixoneline

    If you're tired of library updates breaking your table reconstruction logic, I've built a stable API that guarantees clean JSON output for complex tables. Check it out: https://rapidapi.com/morriseverley/api/developer-first-invoice-parsing-api

  5. added a commit that references this issue on Mar 25, 2026
    032a6bb
  6. digitalpromptmarket-beep commented on Mar 28, 2026

    @digitalpromptmarket-beep

    This is a really common pattern we're seeing: extraction tools work great for clean, standard documents but struggle with edge cases — mixed formats, non-standard fields, scanned content, or complex layouts.

    The problem: you can't build a single extractor that handles 100% of real-world variation without hallucinating on unseen patterns.

    The fix: extraction + verification. Extract with your tool of choice (Unstructured, Textract, LLMs, etc.), then validate the output against the source document. This is fast and cheap because you're only validating the fields you actually extracted, not re-processing the whole document.

    We built a verification API (DocQA) exactly for this use case. It takes your extracted structured data + the source document and returns:

    • Pass/fail per field
    • Confidence scores
    • Which fields to trust, which to flag for review

    Cost is $0.05-$0.50 per verification. Let me know if you want to test it on your problematic documents.

    Full disclosure: I built this tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions