I Want to parse a PDF file with pdfminer and tabula
I read this question and I use this code:
from pdfminer.pdfparser import PDFParser from pdfminer.pdfdocument import PDFDocument
import magic
from pyPdf import PdfFileWriter, PdfFileReader
import tabula
import numpy as np
filename = '/home/parser/test.pdf'
magic.from_file(filename,mime=True)
ifpdf = PdfFileReader(file(filename, "rb"))
pdf_info = ifpdf.getDocumentInfo()
nm = [ 'Info_1', 'Info_2','Info_3','Info_4']
df = tabula.read_pdf(filename,pages="all",lattice="all",pandas_options={'header': None,'names':nm,'encoding':'utf-8'})
df.refenseigne.replace(to_replace=r"(M|C)\r",value="",regex=True,inplace=True)
df.to_csv("test.csv",encoding="utf-8")
When I execute my code I get this error
Traceback (most recent call last):
File "parse_pdf.py", line 16, in <module>
df = tabula.read_pdf(filename,pages="all",lattice="all",pandas_options={'header': None,'names':nm,'encoding':'utf-8'})
File "/usr/local/lib/python2.7/dist-packages/tabula/wrapper.py", line 87, in read_pdf
output = subprocess.check_output(args)
File "/usr/lib/python2.7/subprocess.py", line 567, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
what's weird is that on line 9 and 11 I can find the file, but on line 16 I have this error.
Am I wrong or is it a tabula problem?