如何从 Camelot 获取表格对象单元格列表

问题描述

我正在处理一个使用 Camelot 从 PDF 和图像中读取表格的项目。我们需要找到表格单元格的边界坐标。

Camelot 在这里展示了核心课程,我认为答案可能在这里,但我没有看到。我看到需要坐标作为参数而不是输出函数

https://camelot-py.readthedocs.io/en/master/_modules/camelot/core.html

无论如何我需要找到每个单元格的列表及其坐标。如何做到这一点?

解决方法

您对table.cells

感兴趣

用法示例:

import camelot
tables=camelot.read_pdf('YOUR-PDF-FILEPATH',pages='all')
print(tables[0].cells)

输出:

[[<Cell x1=218.65 y1=698.47 x2=267.14 y2=722.23>,<Cell x1=267.14 y1=698.47 x2=296.18 y2=722.23>,<Cell x1=296.18 y1=698.47 x2=324.98 y2=722.23>,<Cell x1=324.98 y1=698.47 x2=353.78 y2=722.23>,<Cell x1=353.78 y1=698.47 x2=382.83 y2=722.23>,<Cell x1=382.83 y1=698.47 x2=411.63 y2=722.23>,<Cell x1=411.63 y1=698.47 x2=440.43 y2=722.23>,<Cell x1=440.43 y1=698.47 x2=469.23 y2=722.23>,<Cell x1=469.23 y1=698.47 x2=500.91 y2=722.23>,<Cell x1=500.91 y1=698.47 x2=529.96 y2=722.23>],...]

单元格属性列表(由dir(tables[0].cells[0][0])获得): bottom、bound、hspan、lb、left、lt、rb、right、rt、text、top、vspan、x1、x2、y1、y2

您可以尝试并与它们一起玩。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...