Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Camelot borderless table extraction issue

I'm trying hard to extract some borderless table as show in the below image which are from pdf files. I have installed python-camelot as shown here and is working fine for bordered tables only. Please find below details:

platform - Linux-4.5.5-300.fc24.x86_64-x86_64-with-fedora-24-Twenty_Four

sys - Python 3.6.1 (default, May 15 2017, 11:42:04)[GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]

numpy - NumPy 1.15.4

cv2 - OpenCV 3.4.3

camelot - Camelot 0.3.2enter image description here

like image 482
Richie Avatar asked Nov 08 '18 14:11

Richie


1 Answers

To improve the detected area, you can increase the edge_tol (default: 50) value to counter the effect of text being placed relatively far apart vertically. Larger edge_tol will lead to longer textedges being detected, leading to an improved guess of the table area. Let’s use a value of 500.

>>> tables = camelot.read_pdf('edge_tol.pdf', flavor='stream', edge_tol=500)
>>> camelot.plot(tables[0], kind='contour')
>>> plt.show()
>>> tables[0].df
like image 151
Sajjad Manal Avatar answered Oct 10 '22 04:10

Sajjad Manal