提取pdf文檔表格


import   pdfplumber

pdf=pdfplumber.open(',,,,,,,.pdf')

first_page=pdf.pages[0]

print(first_page.extract_text())    #打印第一頁內容

 

#提取其中的表格

first_page.extract_table()    #提取這一頁的第一個表格

first_page.extract_tables()     #提取這一頁內的所有表格

#提取表格時設置表格參數

first_page.extract_table(

table_settings={'

       vertical_strategy':'text',

       'horizontal_strategy':'text'

      }

        )

 

if    not   ''.join(  [  str(i)   for  i in  first_page.extract_text( )   ]  )   == '' :    #這行不為空則繼續執行以下操作

  ''.join( [ str(item)  if  item   else  ''  for  item  in    i[:3]  )

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM