{"data":{"slug":"github-xberg-io-xberg-plugin-ai-rulez-skills-xberg-extracting-tables-8e58165b7769","title":"Extract Tabular Data from PDFs and Images","summary":"Extract structured tabular data from PDFs, spreadsheets, and images. Supports layout-aware detection, multiple output formats, and table model selection.","url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-plugin-ai-rulez-skills-xberg-extracting-tables-8e58165b7769","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-xberg-io-xberg-plugin-ai-rulez-skills-xberg-extracting-tables-8e58165b7769","markdown_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-plugin-ai-rulez-skills-xberg-extracting-tables-8e58165b7769.md","download_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-plugin-ai-rulez-skills-xberg-extracting-tables-8e58165b7769\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"Requires ONNX Runtime for full support; layout and table models are unavailable in WASM builds and on the Android x86_64 emulator.","instructions":"---\ntype: Playbook\ntitle: Extracting Tables\ndescription: Use when extracting tabular data from PDFs, spreadsheets, or images. Covers layout-aware table detection, table model selection, output formats (markdown \/ JSON cells), and known limits.\nx-ai-rulez:\n  kind: skill\n  id: xberg-extracting-tables\n  metadata:\n    name: xberg-extracting-tables\n---\n\n# Extracting tables\n\nUse this when the user wants structured tabular data \u2014 financial\nstatements, scientific tables, invoices, spreadsheet-style PDFs. Xberg\ndetects tables via a layout model (RT-DETR v2) and reconstructs cell\nstructure with a configurable table model.\n\n## Basic usage\n\n```bash\n# Markdown tables embedded in the content stream\nxberg extract report.pdf --layout --content-format markdown\n\n# Structured JSON output, tables appear under result.tables\nxberg extract report.pdf --layout --format json\n```\n\n`--layout` turns on layout-aware extraction; without it, tables fall back\nto plain text reflow and you lose cell boundaries.\n\n## Output shapes\n\nTwo surfaces, picked via `--format` (CLI shape) and `--content-format`\n(content rendering):\n\n- **Markdown tables in `content`** \u2014 `--content-format markdown`. Tables\n  appear inline as `| col | col |` blocks. Good for LLM ingestion.\n- **Structured `tables` array** \u2014 `--format json`. Each entry has\n  `cells[][]` (rows \u00d7 cols), `markdown` (pre-rendered), `page_number`,\n  `bounding_box`. Use this when downstream code needs exact cell access.\n  (`bounding_box` is omitted when no position data is available.)\n\nBoth are populated at once when `--layout` is on. The `tables` array is\nalways structured; the `content` stream switches representation.\n\n```bash\nxberg extract financials.pdf --layout --format json \\\n  | jq '.result.tables[] | {page: .page_number, rows: (.cells | length)}'\n```\n\n## Table models\n\n`--layout-table-model` picks the reconstruction backend:\n\n| Model              | Best for                                              | Notes                                       |\n| ------------------ | ----------------------------------------------------- | ------------------------------------------- |\n| `tatr`             | dense complex tables (academic, financial)            | **Default.** Heaviest, highest accuracy.    |\n| `slanet_auto`      | dispatches per-table to wired\/wireless                | Good when table styles are mixed.           |\n| `slanet_wired`     | tables with visible borders                           | Faster than tatr.                           |\n| `slanet_wireless`  | tables without borders (whitespace-separated)         | For invoices, simple grids.                 |\n| `slanet_plus`      | hybrid wired \/ wireless                               | Lighter than `slanet_auto`.                 |\n| `disabled`         | layout detection only, no table structure             | Use to skip table model cost.               |\n\n```bash\nxberg extract bank-statement.pdf \\\n  --layout --layout-table-model tatr --content-format markdown\n```\n\nDrop `--layout-confidence` when the layout model misses tables (default\nthreshold ~0.5):\n\n```bash\nxberg extract noisy-scan.pdf --layout --layout-confidence 0.3\n```\n\n## Spreadsheets\n\n`.xlsx`, `.ods`, `.csv`, `.tsv` are extracted by dedicated parsers \u2014 no\nlayout model needed. Each sheet becomes a markdown table (or structured\ntable) automatically:\n\n```bash\nxberg extract workbook.xlsx --content-format markdown\nxberg extract data.csv --format json\n```\n\nPass `--no-cache=true` only when iterating on the same file with different\nconfigs.\n\n## Config file alternative\n\n```toml\n# `output_format` in config files equals `--content-format` on the CLI.\noutput_format = \"markdown\"\n\n[layout]\nconfidence_threshold = 0.5\ntable_model = \"tatr\"\n```\n\nThen:\n\n```bash\nxberg extract report.pdf --format json\n```\n\n## Programmatic access\n\nFrom Python, structured tables live on the document in the result envelope\n(`result.results[0].tables`):\n\n```python\nfrom xberg import ExtractInput, extract, ExtractionConfig, LayoutDetectionConfig\n\nconfig = ExtractionConfig(\n    layout=LayoutDetectionConfig(table_model=\"tatr\"),\n    output_format=\"markdown\",\n)\nresult = await extract(ExtractInput(uri=\"report.pdf\"), config)\nfor table in result.results[0].tables:\n    print(table.markdown)        # rendered markdown\n    print(table.cells[0][0])     # cell access\n```\n\nNode.js mirrors this (`extract`, `output.results[0].tables`, camelCase fields).\nSee `..\/..\/references\/python-api.md` and `..\/..\/references\/nodejs-api.md` for full type signatures.\n\n## Known limitations\n\n- **Merged cells** \u2014 reconstructed as repeated values across the spanned\n  region; the merge is not preserved as metadata.\n- **Rotated tables** \u2014 enable `--ocr-auto-rotate true` for image-based\n  PDFs before extraction.\n- **Nested tables** \u2014 flattened. Detection succeeds; structural nesting is\n  lost.\n- **Multi-page tables** \u2014 each page yields a separate `tables[]` entry.\n  Stitch by matching column headers if needed.\n- **ONNX Runtime required** \u2014 layout and table models are unavailable in\n  WASM builds and on the Android x86_64 emulator; native targets ship\n  full support.\n\n## Common failure modes\n\n- **Empty `tables` with `--layout` on** \u2014 confidence threshold too high or\n  table model mismatched. Drop `--layout-confidence` to 0.3, try\n  `--layout-table-model tatr`.\n- **Markdown tables look ragged** \u2014 switch `--layout-table-model` to\n  `slanet_wired` for bordered grids or `slanet_wireless` for invoices.\n- **Slow extraction** \u2014 `tatr` is heavy. Use `slanet_auto` or\n  `slanet_plus` as a default; reach for `tatr` only when accuracy matters.\n\nSee `..\/..\/references\/cli-reference.md` for the full layout flag set and\n`..\/..\/references\/advanced-features.md` for the layout pipeline internals.\n","use_cases":["Extract financial statements from PDFs","Reconstruct scientific tables from scanned documents","Parse invoices with rotated tables","Extract structured data from spreadsheets"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/xberg-io\/xberg\/blob\/ffbf7971796a126fc52f6bb8fb40418772071f61\/plugin\/.ai-rulez\/skills\/xberg-extracting-tables\/SKILL.md","source_commit":"ffbf7971796a126fc52f6bb8fb40418772071f61","license":null,"version":null,"listing_approved_at":"2026-11-16","created_at":"2026-11-15T14:07:58.000000Z","updated_at":"2026-11-16T05:16:54.000000Z","seo_title":"Extract Tabular Data from PDFs and Images","seo_description":"Extract structured tabular data from PDFs, spreadsheets, and images with layout-aware detection and multiple output formats.","seo_keywords":["extract tables from PDF","tabular data extraction","structured data from images","layout-aware table detection","spreadsheet data extraction"]}}