所以这就是我要做的——非常简单。我有一个包含数据的pdf文档,我想用python提取它。在这种情况下,我试图从需要定期读入的固定模板中自动提取数据。在
我使用tabula py包,并使用“read_pdf”函数读取数据。问题是它似乎只读取我需要的表的一部分……更具体地说,它只能在表头中读取。奇怪的是,如果我使用在线表格工具阅读表格,我就不会遇到这个问题。在# Here is the python code to read table content
df = tb.read_pdf(path+name+'.pdf', encoding='latin-1', area=[416.543,25.398,434.903,582.318],spreadsheet=True,pages=2)
# Here is the tabula online tool script:
java -jar tabula-java.jar -a 416.543,25.398,434.903,582.318 -p 2 "$1"
前者产生收益an object of type « None »
后者产生:1 2018 Peterbilt Tracteur routier Some VIN number 230 000 $
在表的头上运行相同的查询将得到所需的结果:
^{pr2}$
前者产生收益Empty DataFrame Columns: [Item, Année, Marque, Carrosserie, No série,
Valeur actuelle] Index: []
而后者会屈服
^{4磅}$
由于tablapy只是java包的包装器,所以我认为两者的行为方式完全相同。我错过了什么?在
Windows 10 64位
表格py v1.0.0
Java v8