Tables are often the most commercially important part of a WooCommerce document. A product catalog may contain dimensions and variation data, a pricing guide may define customer tiers, and a shipping document may map destination, weight, and delivery cost. If a table is reduced to an undifferentiated block of text, retrieval can lose the relationship between a row and its column headings.
Unstructured treats a detected table as a distinct document element rather than assuming that every page is a sequence of paragraphs. That gives a WooCommerce agency two useful representations: readable text for search and language-model context, and structured HTML for applications that need to preserve rows and columns.
Table extraction as an element
When a supported partitioner identifies a table, it produces a Table element. The element has normal element text, which is useful for indexing, and may include table-specific metadata such as text_as_html. The HTML representation can preserve the table’s visual relationships more effectively than plain text.
A simplified result may look conceptually like this:
<Table> text="SKU Shipping class Rate ..." metadata.text_as_html="<table>...</table>"
The exact output depends on the source format, partitioner, extraction strategy, and whether the document contains a machine-readable table or only a visual layout. Agencies should treat table detection as an extraction step that requires validation, not as a guarantee that every PDF table will be recovered perfectly.
Enabling table structure for PDFs
For PDFs, table structure extraction is commonly enabled with the high-resolution strategy and infer_table_structure=True. The high-resolution path uses layout analysis to identify regions such as tables, titles, and text blocks. A typical Python partitioning call is:
from unstructured.partition.pdf import partition_pdf
elements = partition_pdf(
filename="shipping-rates.pdf",
strategy="hi_res",
infer_table_structure=True,
)
for element in elements:
if element.category == "Table":
print(element.text)
print(element.metadata.text_as_html)
Installation requirements and supported options vary by Unstructured version and deployment mode. In a production pipeline, pin the library version, test representative files, and confirm that the required layout and table models are available in the worker environment.
Plain text and HTML serve different jobs
The element’s plain text is usually the best default for embeddings and keyword search. It gives a retrieval system a compact representation that can include headers and cell values. However, plain text can make a row ambiguous. For example, the text Express 12.00 1–2 days does not clearly identify which value is the service name, price, or delivery window if the headers were omitted or reordered.
The text_as_html value is better suited to answer generation, display, auditing, or downstream parsing. It can retain table rows, columns, and header relationships in a form that an application can inspect. A WooCommerce assistant answering “What is the express shipping charge for a 5 kg order to Germany?” can use the HTML representation to reason over the relevant row instead of guessing from a flattened paragraph.
Chunking behavior and table boundaries
Unstructured’s chunking functions operate on document elements and can combine compatible elements into chunks according to character limits and page or title boundaries. Tables deserve special handling because splitting a table in the middle of a row, or separating the header from its values, reduces retrieval quality.
Use a table as a logical unit whenever its size permits. If a table is too large for the target context window, split it by complete rows and repeat the column headings in every derived chunk. Do not split arbitrarily by character count. The row key, SKU, region, or customer tier should remain with the values that describe it.
A basic inspection of chunk output can help identify unsafe splits:
from unstructured.chunking.basic import chunk_elements
chunks = chunk_elements(
elements,
max_characters=3000,
new_after_n_chars=2400,
overlap=200,
)
for chunk in chunks:
print(chunk.category, chunk.text[:120])
The precise behavior of chunking options is version-dependent, so test whether a Table remains intact in the version used by the agency. A practical safeguard is to inspect each resulting chunk’s category and metadata, then route oversized tables to a table-specific splitter instead of allowing a generic splitter to divide them.
A WooCommerce retrieval pattern
For a catalog or operations knowledge base, store both searchable text and the original table representation. A useful record can contain:
- Search text: the table’s normalized text, including column headings.
- Structured content:
metadata.text_as_htmlwhen available. - Source metadata: filename, page number, document identifier, and element identifier.
- Business keys: SKU, product ID, shipping zone, currency, or customer tier extracted during post-processing.
- Validation status: whether required headers and expected cell types were found.
For example, a shipping-rate table can be indexed with text such as “Destination Germany; Weight 0–5 kg; Service Express; Price EUR 12.00” while retaining the original HTML for citation and review. The normalized text improves vector and keyword retrieval; the HTML gives the answer-generation layer a clearer source representation.
Handling malformed and scanned tables
Table extraction can fail when a PDF is scanned, when borders are missing, when cells span multiple rows, or when the reading order is visually complex. Common symptoms include shifted columns, duplicated headers, missing currency symbols, and numbers assigned to the wrong product.
Use a review step for documents that drive prices, tax calculations, inventory, or shipping. Useful checks include:
- Confirm that expected headers such as
SKU,Price, andCurrencyare present. - Verify that numeric cells parse as expected and that currency symbols or ISO currency codes were not dropped.
- Compare the extracted row count with the source document.
- Flag merged cells and multi-line rows for human review.
- Keep the source page reference so an operator can compare the extracted result with the original.
For scanned documents, OCR quality is part of table quality. A high-resolution partitioning strategy may identify the table region, but recognition errors in the underlying scan can still change an SKU or price. Do not silently publish extracted values to WooCommerce when a confidence or validation check fails.
Recommended agency workflow
- Partition the source with a strategy appropriate to its format and enable table structure inference for PDFs where needed.
- Separate
Tableelements from ordinary narrative elements. - Preserve both plain text and
text_as_htmlwhen the latter exists. - Chunk narrative content with normal rules, but keep tables intact or split them by complete rows with repeated headers.
- Normalize business fields such as SKU, price, currency, region, and weight range into metadata or a dedicated data model.
- Validate high-impact values before sending them to a search index, chatbot, product import, or WooCommerce automation.
This approach makes Unstructured’s table output useful beyond visual document search. It allows an agency to retrieve table content efficiently, retain enough structure for accurate answers, and apply business-specific validation before extracted data affects a store.