pdftables / python-pdftables-api

Python library to interact with https://pdftables.com API
https://pdftables.com/api
BSD 3-Clause "New" or "Revised" License
85 stars 33 forks source link

Convert multiple files from a folder #24

Closed imv7 closed 4 years ago

imv7 commented 4 years ago
import pdftables_api
import os

c = pdftables_api.Client('XYZ')
root_dir = 'C:\PythonTests\pdf'

for directory, subdirectories, files in os.walk(root_dir):
    for file in files:
        print (file)
        c.html(file, file) 

File "c:/PythonTests/for.py", line 10 c.html('file, file) ^ SyntaxError: EOL while scanning string literal

I am trying to get every single file and convert it. How to fix this issue?

imv7 commented 4 years ago

Solved with:

import pdftables_api
import os

c = pdftables_api.Client('')

file_path = "C:\\PythonTests\\"

for file in os.listdir(file_path):
    if file.endswith(".pdf"):
        c.html(os.path.join(file_path,file), file+'.html')