GithubHelp home page GithubHelp logo

yellowspots / pdf-to-csv-table-extactor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vitali84/pdf-to-csv-table-extactor

0.0 0.0 0.0 180 KB

Extract tables from scanned documents pdf into csv file using ocr and image processing

License: Do What The F*ck You Want To Public License

Python 100.00%

pdf-to-csv-table-extactor's Introduction

Table data extractor into CSV from PDF of scanned images

This is a basic but usable Example of python script that allows to convert a pdf of scanned documents (images), extract tables from each pdf page using image processing, and using OCR extract the table data into into one CSV file, while keeping correct table structure.

This code has quite a bit assumptions (the table is largest object in the pages), but it can be useful to convert printed excel tables back into digital copy

Prerequisites

install the following Packages (versions the script was developed on)

  • python 3.6
  • tesseract-ocr 4.0.0
  • opencv 3.4.4
  • pip requirements.txt

usage:

python pdf-to-csv-cv.py -p test.pdf

this will create test.pdf.csv output file

Algorithm

1. Extract image from each pdf page

original

2. Threshold + blur + bitwise not image:

thresholded

3. find largest contour with largest area (hopefully our table), fix perspective using four point transform

extracted

4. find rows and columns, using morphological operations with custom kernels

horizontal_vertical_contours

5. use tesseract ocr, for text extraction from each cell

6. throw all the extracted data into one large CSV, while keeping the original table structure

result

Notes

The performance is mostly affected by the OCR package, both speed and accuracy, feel free to play with tesseract flags

Author

Vitali Mogilevsky

License

wtfpl - see the LICENSE file for details

pdf-to-csv-table-extactor's People

Contributors

vitali84 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.