ichadhr
10/4/2018 - 7:48 AM

Simple use tabula.jar with python

Simple use tabula.jar with python #tabula #python

# running tabula
def tabula(jarfile, coordinate, pathFile) :

output = self.launchWithoutConsole('java', ['-jar', str(jarfile), '-p', 'all', '-a', str(coordinate), str(pathFile)])

return output
        

# Subprocess without console (PyInstaller)
def launchWithoutConsole(command, args):
"""Launches 'command' windowless and waits until finished"""
startupinfo = subprocess.STARTUPINFO()
stdin = subprocess.PIPE
stdout = subprocess.PIPE
stderr = subprocess.PIPE
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
tmpRes, err = subprocess.Popen([command] + args, startupinfo=startupinfo, stdin=stdin, stderr=stderr, stdout=stdout).communicate()

result = tmpRes.decode('utf-8').splitlines()

return result