使用Python将pdf表连接到一个excel表

问题描述

我正在使用tabula是为了在接下来的pdf fileconcat全部tables

成为excel格式的一张桌子。

这是我的代码:

from tabula import read_pdf
import pandas as pd

allin = []
for page in range(1,115):
    table = read_pdf("goal.pdf",pages=page,pandas_options={'header': None})[0]
    allin.append(table)


new = pd.concat(allin)

new.to_excel("out.xlsx",index=False)

我也尝试了以下方法:

from tabula import read_pdf
import pandas as pd

table = read_pdf("goal.pdf",pages='all',pandas_options={'header': None})

new = pd.concat(table,ignore_index=True)

new.to_excel("out.xlsx",index=False)

当前输出:check

但是从页面#91开始面临的问题开始出现,我发现excel文件中的数据格式不正确。

我已经单独调试了页面,我不知道为什么格式错误,尤其是格式相同的情况。

from tabula import read_pdf
import pandas as pd

table = read_pdf("goal.pdf",pages='91',pandas_options={'header': None})[0]


print(table)

enter image description here

示例

from tabula import read_pdf
import pandas as pd

table = read_pdf("goal.pdf",pages='90-91',index=False)

在这里,我已经运行了两个代码90和91。

从第48行开始,您将看到区别here

您将在此处注意到将名称和地址放在一个单元格中的问题。而城市和州也可以一次通话

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)