LoginSignup
0
0

More than 3 years have passed since last update.

新潟県の Go To EATの加盟店一覧のPDFをCSVに変換

Last updated at Posted at 2020-10-10

新潟県Go To Eatキャンペーンの利用できる店舗一覧(PDF)をCSVに変換

10/28現在はPDFがダウンロードできません
こちらに新潟県の Go To EATの加盟店一覧をスクレイピングしてCSVに変換の記事を作成しました

PDFからCSV(現在は利用できません)

# PDFをダウンロード
wget https://niigata-gte.com/pdf/shop-list.pdf -O data.pdf

apt install python3-tk ghostscript
pip install camelot-py[cv]

コマンド

camelot -p all -o data.csv -f csv -strip '\n' -split lattice -scale 40 data.pdf

Python

import camelot
import pandas as pd

tables = camelot.read_pdf(
    "data.pdf", pages="all", split_text=True, strip_text="\n", line_scale=40
)

df = pd.concat(
    [
        table.df.iloc[1:].set_axis(
            ["取扱店コード", "ジャンル", "店舗名", "住所", "電話番号", "テイクアウト", "デリバリー"], axis=1
        )
        for table in tables
    ]
)

df.to_csv("niigata.csv", encoding="utf_8_sig")
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