Skip to main content
Version: 2.0

Querying Table Data

Tables in PDFs are hard to query, because their structure is unpredictable and often complex. This can prevent researchers and analysts from extracting specific data points. Our tabular data extraction capability enables users to query and extract valuable information from structured tabular data embedded in PDFs, enhancing the overall data retrieval and analysis process.

Users can query specific table cells, entire rows, or even whole tables to access actionable insights from structured data in PDFs. Querying tables provides enhanced context by displaying relevant tables, titles, and row-level details.

This tabular data extraction capability is especially beneficial for organizations working with financial reports like 10-Q, 10-K, and S1 filings. By streamlining the extraction process and improving querying accuracy, users can derive actionable insights more effectively.

  • Streamline report analysis across various fields
  • Improve accuracy in data extraction from PDF tables
  • Enable more efficient querying of specific data in cells

Extraction capabilities

  • Extract tabular data from PDF documents
  • Query specific cell values within tables
  • Semantic comparison between cell contents
  • Duplicate table references are removed before reaching the user

Supported table formats

  • Clear, single-row headers
  • Consistent data types within columns
  • Column merged cells
  • Simple row-column structure without merged cells

Limitations

  • English only
  • Cannot perform complex mathematical comparisons or computations across multiple cell values
  • Merged rows may be detected as empty cells
  • Does not support extracting data from scanned-in images of tables

Enable table data extraction

You can ingest PDF table data with the Vectara Console, File Upload API, or Indexing API.

Vectara Console

To enable table data extraction in the UI:

  1. Open a corpus and select the Data tab.
  2. Click Load data into the corpus.
  3. Click Upload files.
  4. Enable the Extract tabular data from PDFs option.
  5. Upload your PDFs that contain table data.

Extract table data from PDFs toggle

File Upload API

To extract tables during document ingestion, set the extract_tables option in the table_extraction_config parameter of the file upload request to true in the multipart/form-data payload. For example, table_extraction_config={"extract_tables":true};type=application/json. By default, this parameter is set to false.

Indexing API

The Indexing API also supports table extraction when creating or updating documents directly.

Core documents

For core documents, you define tables explicitly within the document. Use this schema when you need precise control over how document parts and tables are structured.

  1. Set the document type to core.
  2. Add your tables to the tables object as an array.
  3. Define each table with its id, title, and data. The data object contains the headers and rows of the table.
  4. Link each document part to its relevant table using the table_id field in document_parts.

Structured documents

For structured documents, you organize tables within sections. Use this schema to simplify document ingestion while allowing Vectara to process sections and tables automatically.

  1. Set the document type to structured.
  2. Within the sections object, add your tables to the tables object as an array.
  3. Define each table with its id, title, and data. The data object contains the headers and rows of the table.

View extracted tables in search results

If a corpus contains data extracted from tables, search results can contain table rows, table titles, or whole tables. In each of these cases, the entire table from which this data was extracted is provided to the generative LLM, if one is configured as part of the query.

When an application consumes these table-based search results, it can key off table-specific metadata that’s shaped like this:

{
vectara: {
table_id: string,
is_table_summary: boolean (optional),
is_table_title: boolean (optional),
row_num: integer (optional)
}
}
  • table_id: The ID that identifies the table. You can use it to retrieve the entire table with the Documents API.
  • is_table_summary: This value is “true” if the search result is for the whole table. It’s called a “table summary” because we match against a summary of the table, rather than the entire original table.
  • is_table_title: This value is “true” if the search result is for the title of the table.
  • row_num: This value is a number if the search result is for a specific row of the table.

When you open a corpus in the UI and select the Data tab, you can click on each uploaded document and select the Tables tab to view the ingested table data as well as view the rendered table. For more details, see Manage Documents.

Table examples

This section contains some table examples.

Quarterly financial statements

This table summarizes the financial performance for Q1, Q2, and Q3 of 2024, detailing revenue, expenses, net income, and earnings per share (EPS).

QuarterRevenueExpensesNet IncomeEarnings per Share (EPS)
Q1 2024$5,000,000$3,000,000$2,000,000$1.50
Q2 2024$6,000,000$3,500,000$2,500,000$1.75
Q3 2024$6,500,000$4,000,000$2,500,000$1.80

Bill of materials (BOM)

This table lists the bill of materials (BOM) for Laptop X, outlining its component hierarchy, quantities, and suppliers.

BOM IDProductComponent LevelComponent NameQuantityUnitSupplier
BOM001Laptop X0Laptop X1pieceIn-house
BOM001Laptop X1Motherboard1pieceTechComp Inc
BOM001Laptop X1CPU1pieceProcessorTech
BOM001Laptop X1RAM2pieceMemory Supplier Co
BOM001Laptop X1SSD1pieceStorageSolutions Inc
BOM001Laptop X1Display1pieceScreenMakers
BOM001Laptop X1Battery1piecePowerCells Ltd

Clinical trial results

This table presents the results of a clinical trial, showing patient demographics, baseline and follow-up scores, and any reported side effects.

Patient IDTreatment GroupAgeGenderLocationBaseline ScoreWeek 4 ScoreWeek 8 ScoreSide Effects
PAT001Drug A45FNew York7.56.24.8Mild nausea
PAT002Placebo52MChicago7.87.57.2None
PAT003Drug A39MLos Angeles8.15.93.7Headache
PAT004Drug A61FMiami7.35.64.1Dizziness
PAT005Placebo57FBoston7.97.77.5Fatigue
PAT006Drug A48MSeattle8.36.54.4Mild rash
PAT007Placebo55FDenver7.67.47.1None