gpt4 book ai didi

python - 当Python tabula-py表格中有换行符时,如何读取pdf中的表格?

转载 作者:行者123 更新时间:2023-12-01 07:51:24 36 4
gpt4 key购买 nike

我尝试使用Python包tabula-py来读取table在pdf中,pdf表格单元格中的换行符似乎会将原始单元格中的内容分成多个单元格。

我尝试搜索各种python包来解决这个问题。看来 tabula-py 是将 pdf 表转换为 pandas 数据的最稳定的包。不过,如果这个问题解决不了,我就得求助online service ,这将为我产生理想的 Excel 输出。

from tabula import read_pdf
df=read_pdf("C:/Users/Desktop/test.pdf", pages='all')

我预计 pdf 表可以使用 this 正确转换.

最佳答案

Tabula 不再提供“电子表格”选项。相反,使用“lattice”选项来避免换行符分隔成新行。代码如下:

import tabula

# Read pdf into DataFrame
df = tabula.read_pdf("FDA EPC Text Phrases (updated March 2018.pdf", pages='all',
lattice=True)
print(df)

关于python - 当Python tabula-py表格中有换行符时,如何读取pdf中的表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56197612/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com