【问题标题】:how to get list of table objects (cells) from Camelot如何从 Camelot 获取表格对象(单元格)列表
【发布时间】:2021-06-21 13:56:50
【问题描述】:

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

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

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

无论如何,我需要找到每个单元格的列表及其坐标。该怎么做?

【问题讨论】:

    标签: python-3.x pdf python-camelot


    【解决方案1】:

    你对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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多