Convert the list of available stores (PDF) in Niigata Go To Eat Campaign to CSV
#Download 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(
["Dealer code", "Genre", "Store name", "Street address", "phone number", "Take-out", "delivery"], axis=1
)
for table in tables
]
)
df.to_csv("niigata.csv", encoding="utf_8_sig")
Recommended Posts