こちらにまとめました imabari.hateblo.jp
インストール
!apt install ghostscript !pip install camelot-py[cv]
ダウンロード
!wget https://www.who.int/docs/default-source/coronaviruse/situation-reports/20200219-sitrep-30-covid-19.pdf
プログラム
- レポートの日にちによってページ番号が変わります
import pandas as pd import camelot # pages = ページ番号 tables = camelot.read_pdf('20200219-sitrep-30-covid-19.pdf', pages='4,5', split_text=True, strip_text='\n', line_scale=40) # 中国 df0 = tables[0].df tables[0].to_csv("china.csv") # 世界 df1 = tables[1].df tables[1].to_csv("country.csv") # 日本 df1.set_index(0, inplace=True) s1 = df1.loc["Japan", :] s1.str.extract("(\d+) \((\d+)\)")