python - Python-Camelot 提取空表
问题描述
我正在使用 Camelot 通过以下命令提取 PDF 的多个部分。
cgl_section = camelot.read_pdf(filename, flavor='stream',
table_areas=['35,490,155,483', '53,480,110,470', '117,480,155,470',
'38,469,106,456', '39,454,105,445', '38,430,155,420',
'38,418,77, 410'])
当 PDF 实际包含这些区域中的数据时,这运行良好。但我不希望在每个解析的 PDF 中都有数据,有些返回的是空的。当返回的数据不是表格并且只有一列时,我收到以下错误。
UserWarning: No tables found in table area 1
和
ValueError: min() arg is an empty sequence
我需要一种方法来提取所有 PDF 中的这些特定区域,但之后忽略空的区域。需要能够有序地使用提取的数据。
也欢迎任何其他建议
TIA
解决方案
也许选项 table_regions(在 0.7 中引入)可以帮助你。
https://camelot-py.readthedocs.io/en/master/user/advanced.html#specify-table-regions
When table_regions is specified, Camelot will only analyze the specified regions to look for tables.
推荐阅读
- typescript - Axios - 解析 Typescript 接口
- php - PHP 电子表格日期验证
- java - 加密数据,使用 UDP 发送到服务器,然后解密
- sql - 我在 oracle sql 中的左连接没有返回左表的每个元素
- python - 输入值以百分比返回预测
- laravel - 如何在路由中使用 slug
- java - java - 如何将Array List中某些字段的一些不同值与其他List进行比较并返回java spring中的差异?
- php - 点击链接时无法打开上传的文件
- javascript - 遍历数组并从循环中调用数据函数
- laravel - Laravel 未在 Windows 上连接到 Docker/docker-compose 上的数据库