xberg-extracting-tables
它能做什么
这项技能说明如何使用支持版面识别的检测方式从文档中获取表格。适合需要以可用形式获取财务报表、发票或研究表格的人。
适用场景
- ✓当你需要 PDF 报告、发票或财务报表中的表格时。
- ✓当你希望把表格数据整理为干净的 Markdown,供 AI 阅读时。
- ✓当你需要为其他软件提供结构化文件中的精确单元格数值时。
技能链接
https://github.com/xberg-io/xberg/blob/main/plugin/.ai-rulez/skills/xberg-extracting-tables/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请把这份财务报表 PDF 中的所有表格提取为结构化文件,我可以用电子表格打开。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会开启版面识别,使工具能找到表格边界,然后根据你选择的输出方式,返回文本中的 Markdown 表格,或结构化的单元格列表。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Extracting tables
Use this when the user wants structured tabular data — financial statements, scientific tables, invoices, spreadsheet-style PDFs. Xberg detects tables via a layout model (RT-DETR v2) and reconstructs cell structure with a configurable table model.
Basic usage
# Markdown tables embedded in the content stream
xberg extract report.pdf --layout --content-format markdown
# Structured JSON output, tables appear under result.tables
xberg extract report.pdf --layout --format json
--layout turns on layout-aware extraction; without it, tables fall back
to plain text reflow and you lose cell boundaries.
Output shapes
Two surfaces, picked via --format (CLI shape) and --content-format
(content rendering):
- Markdown tables in
content—--content-format markdown. Tables appear inline as| col | col |blocks. Good for LLM ingestion. - Structured
tablesarray —--format json. Each entry hascells[][](rows × cols),markdown(pre-rendered),page_number,bounding_box. Use this when downstream code needs exact cell access. (bounding_boxis omitted when no position data is available.)
Both are populated at once when --layout is on. The tables array is
always structured; the content stream switches representation.
xberg extract financials.pdf --layout --format json \
| jq '.result.tables[] | {page: .page_number, rows: (.cells | length)}'
Table models
--layout-table-model picks the reconstruction backend:
| Model | Best for | Notes |
|---|---|---|
tatr |
dense complex tables (academic, financial) | Default. Heaviest, highest accuracy. |
slanet_auto |
dispatches per-table to wired/wireless | Good when table styles are mixed. |
slanet_wired |
tables with visible borders | Faster than tatr. |
slanet_wireless |
tables without borders (whitespace-separated) | For invoices, simple grids. |
slanet_plus |
hybrid wired / wireless | Lighter than slanet_auto. |
disabled |
layout detection only, no table structure | Use to skip table model cost. |
xberg extract bank-statement.pdf \
--layout --layout-table-model tatr --content-format markdown
Drop --layout-confidence when the layout model misses tables (default
threshold ~0.5):
xberg extract noisy-scan.pdf --layout --layout-confidence 0.3
Spreadsheets
.xlsx, .ods, .csv, .tsv are extracted by dedicated parsers — no
layout model needed. Each sheet becomes a markdown table (or structured
table) automatically:
xberg extract workbook.xlsx --content-format markdown
xberg extract data.csv --format json
Pass --no-cache=true only when iterating on the same file with different
configs.
Config file alternative
# `output_format` in config files equals `--content-format` on the CLI.
output_format = "markdown"
[layout]
confidence_threshold = 0.5
table_model = "tatr"
Then:
xberg extract report.pdf --format json
Programmatic access
From Python, structured tables live on the document in the result envelope
(result.results[0].tables):
from xberg import ExtractInput, extract, ExtractionConfig, LayoutDetectionConfig
config = ExtractionConfig(
layout=LayoutDetectionConfig(table_model="tatr"),
output_format="markdown",
)
result = await extract(ExtractInput(uri="report.pdf"), config)
for table in result.results[0].tables:
print(table.markdown) # rendered markdown
print(table.cells[0][0]) # cell access
Node.js mirrors this (extract, output.results[0].tables, camelCase fields).
See ../../references/python-api.md and ../../references/nodejs-api.md for full type signatures.
Known limitations
- Merged cells — reconstructed as repeated values across the spanned region; the merge is not preserved as metadata.
- Rotated tables — enable
--ocr-auto-rotate truefor image-based PDFs before extraction. - Nested tables — flattened. Detection succeeds; structural nesting is lost.
- **Multi-page table
常见问题
为什么要开启版面设置?
如果不开启,表格会被当作普通文字重新排列,单元格边界就会丢失。
我应该选择哪种输出?
Markdown 表格适合 AI 阅读,结构化列表则适合需要精确单元格的软件。
它每次都能正确识别表格吗?
不一定。这项技能列出了已知的局限,因此请将结果与原始文档进行核对。
详情
作者的原始描述
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.
repo: xberg-io/xberg
热度
- GitHub 星标
- 9.5k
- 排名
- #12271
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
xberg-batch-extraction
9.5k帮你的智能体使用 Xberg 一次处理大量文档,共用一组选项,限制并行工作量,并让失败的文件不会中断整个任务。
xberg-chunking
9.5k帮你的智能体把长文档文字切分为较小的片段,用于 AI 提示或搜索索引,可设置大小并可选择重叠部分。
xberg-extracting-keywords
9.5k帮你的智能体使用 Xberg 的关键词设置,从文档中提取主要关键词或关键短语,并检测文档语言。
xberg-extracting-with-ocr
9.5k帮你的智能体使用 OCR 从没有文字层的扫描 PDF、照片和图片中读取文字,并可选择语言包。