我在 pdf 檔案中有一張表格。有 x、y 和 z 列。我只想取 x 列。可以使用python嗎?如果是這樣,如何?
然后我想繪制 x 與 y。我該怎么做(使用表中的資料)
uj5u.com熱心網友回復:
第 1 步:使用 tabula-py
示例中使用的方法是:
read_pdf():從給定地址的 PDF 檔案的表格中讀取資料
tabulate():以表格形式排列資料
代碼
from tabula import read_pdf
from tabulate import tabulate
#reads table from pdf file
df = read_pdf("filename.pdf",pages="all") #address of pdf file
print(tabulate(df))
現在你得到輸出
uj5u.com熱心網友回復:
您可以嘗試使用表格來實作它。它有 python 包裝器,可以從 PDF 讀取表格并將它們轉換為 pandas DataFrame。
制表法:https ://tabula.technology/
Python 包裝器:https ://pypi.org/project/tabula-py/
uj5u.com熱心網友回復:
查看 PDF 決議庫tabula-py,它從 PDF 檔案中提取表格。
然后決議你的表
import tabula
table = tabula.read_pdf(<file path> ,pages=<number of pages>)
用各自的值替換和。
它應該回傳一個 pandas 資料框串列,您可以進一步使用它來提取您需要的列。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/462042.html
