How to extract text from pdf in Python 3.7

后端 未结 10 1185
后悔当初
后悔当初 2020-12-29 10:19

I am trying to extract text from a PDF file using Python. My main goal is I am trying to create a program that reads a bank statement and extracts its text to update an exce

10条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-29 11:04

    I have tried many methods but failed, include PyPDF2 and Tika. I finally found the module pdfplumber that is work for me, you also can try it.

    Hope this will be helpful to you.

    import pdfplumber
    pdf = pdfplumber.open('pdffile.pdf')
    page = pdf.pages[0]
    text = page.extract_text()
    print(text)
    pdf.close()
    

提交回复
热议问题