Kreuzberg.Table (kreuzberg v4.0.4)
View SourceStructure representing an extracted table from a document.
Contains table structure information including cells, rows, columns, and optional metadata like markdown representation or cell properties.
Fields
:cells- Two-dimensional list of table cells [[cell1, cell2], ...]:rows- Alternative representation: list of row structures:columns- Optional list of column metadata:headers- Optional list of header cell values:markdown- Optional markdown representation of the table:html- Optional HTML representation of the table:page_number- Page number where table appears (if available):bounds- Optional bounding box coordinates [x1, y1, x2, y2]
Examples
iex> table = %Kreuzberg.Table{
...> cells: [["Name", "Age"], ["Alice", "30"], ["Bob", "25"]],
...> headers: ["Name", "Age"],
...> markdown: "| Name | Age |\n|------|-----|\n| Alice | 30 |"
...> }
iex> table.headers
["Name", "Age"]
Summary
Functions
Returns the number of columns in the table.
Creates a new Table struct from a map.
Returns the number of rows in the table.
Converts a Table struct to a map.
Types
Functions
Returns the number of columns in the table.
Parameters
table- ATablestruct
Returns
The number of columns, or 0 if cells are not available.
Examples
iex> table = %Kreuzberg.Table{cells: [["A", "B"], ["1", "2"]]}
iex> Kreuzberg.Table.column_count(table)
2
Creates a new Table struct from a map.
Converts a plain map (typically from NIF/Rust) into a proper struct.
Parameters
data- A map containing table fields
Returns
A Table struct with matching fields populated.
Examples
iex> table_map = %{
...> "cells" => [["A", "B"], ["1", "2"]],
...> "headers" => ["A", "B"]
...> }
iex> Kreuzberg.Table.from_map(table_map)
%Kreuzberg.Table{
cells: [["A", "B"], ["1", "2"]],
headers: ["A", "B"]
}
Returns the number of rows in the table.
Parameters
table- ATablestruct
Returns
The number of rows, or 0 if cells are not available.
Examples
iex> table = %Kreuzberg.Table{cells: [["A", "B"], ["1", "2"]]}
iex> Kreuzberg.Table.row_count(table)
2
Converts a Table struct to a map.
Useful for serialization and passing to external systems.
Parameters
table- ATablestruct
Returns
A map with string keys representing all fields.
Examples
iex> table = %Kreuzberg.Table{
...> cells: [["A", "B"]],
...> headers: ["A", "B"]
...> }
iex> Kreuzberg.Table.to_map(table)
%{
"cells" => [["A", "B"]],
"headers" => ["A", "B"],
"rows" => nil,
...
}