본문 바로가기

Python

PDF 자료(표 데이터) 추출

1. 일부 보고서에서 자료를 뽑아야 하는데 PDF이다.

https://da-nika.tistory.com/86

 

Python PDF extract tool 정리

 언어의 한계상 대부분이 그렇듯 영어는 인식률이 높지만 한글은 아직 발전해야 할 부분이 많다. 1. OCR_SPACE def ocr_space(filename, overlay=False, api_key='', language='eng'): payload = {'isOverlayRequ..

da-nika.tistory.com

   위 사이트에 정리가 잘 되어 있는 것 같고.

 

2. 보다 세부적으로는

https://github.com/camelot-dev/camelot/wiki/Comparison-with-other-PDF-Table-Extraction-libraries-and-tools

 

camelot-dev/camelot

A Python library to extract tabular data from PDFs - camelot-dev/camelot

github.com

   위 영문 사이트가 낫다.

 

3. camelot이 낫다는 견해에 따라 설치를 위해

https://pypi.org/project/camelot-py/

 

camelot-py

PDF Table Extraction for Humans.

pypi.org

    위 사이트를 참조해서 설치하면 된다.

 

4. 다만 설치 중 맞이하는 몇 가지 문제는

 

  4-1. Camelot mportError: cannot import name 'PDFTextExtractionNotAllowed' from 'pdfminer.pdfpage'

      https://stackoverflow.com/questions/63004650/camelot-mporterror-cannot-import-name-pdftextextractionnotallowed-from-pdfmi

 

Camelot mportError: cannot import name 'PDFTextExtractionNotAllowed' from 'pdfminer.pdfpage'

After install package: So the problem that dependency just always install new versions of packages. import camelot ImportError: cannot import name 'PDFTextExtractionNotAllowed' from 'pdfminer.pdfpa...

stackoverflow.com

 

   4-2. RuntimeError: Please make sure that Ghostscript is installed

        https://github.com/atlanhq/camelot/issues/282

 

RuntimeError: Please make sure that Ghostscript is installed · Issue #282 · atlanhq/camelot

Hello, Trying to run a single line: (Python 2.7.15 under Pycharm) import camelot tables = camelot.read_pdf(inpFile) Full Stack: C:\Python27\python.exe "C:\Program Files\JetBrains\PyCharm 2018....

github.com

 

5. 그렇지만 완전한 형태의 표 추출은 불가능하다....