0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

「DPC導入の影響評価に係る調査」実施説明資料のPDF内のICDコードをCSVに変換

Posted at

2022年度「DPC導入の影響評価に係る調査」実施説明資料をダウンロード

!wget https://www01.prrism.com/dpc/2022/file/setumei_20220331.pdf

プログラム

!apt update
!apt install ghostscript
!pip install camelot-py[cv]
import camelot
import pandas as pd

# ページ範囲
pages = "145-168"

tables = camelot.read_pdf("setumei_20220331.pdf", pages=pages, split_text=True)

dfs = [pd.DataFrame(table.data[1:], columns=table.data[0]) for table in tables]

# 結合
df = pd.concat(dfs).reset_index(drop=True)

# 列名の改行を除去
df.columns = df.columns.str.replace("\s", "", regex=True)

df

df.to_csv("result.csv", encoding="utf_8_sig", index=False)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?