【问题标题】:Exporting Table from a pdf file从 pdf 文件导出表格
【发布时间】:2021-11-09 17:40:35
【问题描述】:

我需要从 pdf 中导出表格并选择特定的列。 我已经设法通过“表格”、“表格”导出,但是它没有以正确的格式导出。在原始文件中,有 5 列,但在导出后我完全得到 3 列,因为由于某种原因,前三列被视为一列。 enter image description here

这是原始表格的表格: enter image description here

下面是我的输出代码:

enter image description here

enter image description here

【问题讨论】:

  • 感谢您的评论。正好被当做一列的那一列本来就是由3列组成的,所以只是想着如何将它们分开。
  • 请提供足够的代码,以便其他人更好地理解或重现问题。
  • 导入的包 (tabulate, pandas, tabulate.io) file= "name of file" dfs = read_pdf(file, pages="all", pandas_options={'header':None}) dfs[ 0].columns = ["结构","纬度","经度"] lat = dfs[0][3:] lat.iloc[0]["经度"]
  • 我添加 3 列而不是 5 列的原因,因为它不会以其他方式运行。我从一列得到值:'16° 03' 53.80628"'。现在尝试将其导出为十进制。

标签: python pandas dataframe tabulate


【解决方案1】:

试试这个:

dfs = read_pdf(file, pages="all",  pandas_options={'header':None})

【讨论】:

  • 非常感谢,现在我得到没有列名的表,我可以手动分配。我无法理解的一点是,为什么它创建了 3 列而不是 5 列的表,因为它在原始表中
  • 可能是因为合并了单元格。我必须用你的 pdf 进行测试才能确定。
  • 感谢您的支持。很抱歉,我没有分享文件的权利。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-06-22
  • 1970-01-01
  • 1970-01-01
  • 2015-01-21
  • 2020-05-01
  • 1970-01-01
  • 2014-05-26
相关资源
最近更新 更多