ใช้โมดูล Tabula-py แปลง PDF เป็น CSV ต้องมี Java ติดตั้งในระบบ
ขั้นตอน
- ติดตั้ง:
pip install tabula-py - อ่าน PDF: read_pdf("file", pages='all')
- แปลงเป็น CSV: tabula.convert_into("input.pdf", "output.csv", output_format="csv", pages='all')
ตัวอย่างโค้ด
# Import the required Module
import tabula
# Read a PDF File
df = tabula.read_pdf("IPLmatch.pdf", pages='all')[0]
# convert PDF into CSV
tabula.convert_into("IPLmatch.pdf", "iplmatch.csv", output_format="csv", pages='all')
print(df)
ผลลัพธ์
แปลงไฟล์ PDF เป็น CSV (Excel) สำเร็จ
