跳到正文

PDF 转 CSV

把 PDF 里的表格取出来,存为逗号分隔的文件。

在你的设备上处理

这款工具完全在你的浏览器中运行。文件从不上传,你可以在浏览器的网络标签中亲自验证这一点。 亲自验证:打开浏览器的网络标签观察。你会看到一个查询你是否还有剩余任务的小请求,只包含工具名称和一段哈希,绝不会包含文件。

这款工具的作用

A PDF has no idea what a table is. There are no cells and no rows in the file, only text placed at coordinates that happen to line up, so recovering a table means finding the columns again. This tool clusters the horizontal positions of every text run, looks for a stretch of lines whose runs all fall into the same bands, and writes what it finds as CSV. Because it is inference rather than reading, every table comes with a confidence score, and the threshold is yours to set.

The usual case is numbers you would otherwise retype: a bank statement that only arrives as a PDF, invoice lines that have to be reconciled, a price list from a supplier, or an export from a system that offers PDF and nothing else.

工作原理

  1. Drop the PDF onto this page. If it is a scan with no text layer, you are sent to OCR PDF rather than given an empty spreadsheet.
  2. Pick the delimiter. Comma is standard; semicolon is what Excel expects in most of Europe; tab suits pasting straight into a sheet.
  3. Set the confidence threshold. 55 per cent is the default; lower it to catch loosely aligned tables, raise it if prose is being mistaken for one.
  4. Choose one file per table, or a single file with the tables one after another.
  5. Press Extract tables. Each output shows its page and its confidence, so a doubtful table is visible as doubtful before you use it.

The detail that separates a table detector that works from one that does not is right alignment. Number columns are set flush right, so their runs share an end position rather than a start position, and a detector that clusters only on where text begins misses every financial table - which is most of what anybody converts. Both edges are clustered here.

Nothing is returned below the confidence threshold, and that is a deliberate refusal rather than a gap. A spreadsheet full of misaligned fragments looks like a result and is worse than no result, because someone will use it.

The threshold is a real dial. At 30 per cent almost any run of aligned lines is offered, which is useful for a loosely typeset table you already know is there. At 90 per cent only tables with clean, consistent columns survive, which is what you want when converting a hundred pages unattended. The default of 55 is where a typical report's tables come through and its paragraphs do not.

Detection and writing both happen in your browser. The numbers in a bank statement are about as sensitive as a document gets, and none of them are transmitted: the PDF is read and the CSV written without any part of either reaching a network.

这款工具做不到的事

  • Ruling lines are ignored. Columns are found from where the text sits, so a heavily bordered table whose text does not line up is still missed, and a table with no borders at all converts fine as long as it is aligned.
  • Merged and spanning cells flatten. A cell spanning three columns is written into one of them and the rest are left empty, because CSV has no way to say that a cell covers more than one column.
  • A scanned table has no text to cluster, so nothing is found. Run OCR PDF first to add a text layer, then come back.

常见问题

它是怎么找到表格的?
靠几何位置。表格表现为一连串相邻的行,其文字落在相同的竖直带里。每一行的左右两端都会被聚类,因为数字列是右对齐的,否则检测器根本看不见它们。每个候选都会得到一个置信度分数,低于你阈值的一律丢弃,而不是硬猜。
明明有一张表却被漏掉了。现在怎么办?
调低置信度阈值——40% 能拾起大多数默认会拒绝的、对齐较松的表格。如果还是没用,那张表的文字很可能根本没有对齐成列,这在单元格大量换行时会发生;PDF 转文字至少能把内容交给你手动处理。
我该选哪种分隔符?
如果文件不是要进欧洲版 Excel,就用逗号。如果你所在地区的数字用逗号作小数点,就用分号,因为这时 Excel 读分号分隔的文件,反而会把逗号分隔的弄乱。若要直接粘进已打开的电子表格,制表符最保险。
它能从扫描页里读出表格吗?
单靠它不行。扫描件是图像,没有可供聚类的文字位置。先运行 OCR 文字识别,表格就变得可检测了——不过数字上的 OCR 准确度值得逐格核对后再采信。
文件会被上传到什么地方吗?
不会。PDF 的读取和 CSV 的写出全在你的浏览器里完成,所以银行对账单或工资表绝不会离开你打开它的这台机器。没有账户,没有每日上限,断网时这款工具照样能用。

相关工具