Thank you for posting your code, and the error message, but can you
please post the full traceback of the exception, starting with the line
“Traceback…” and ending with the error message?
The information in the traceback is just as important as the error
message, possibly even more so.
Please copy and paste it as text, not a screen shot or photo.
Thanks Benjamin, that’s exactly what I meant, except that it looks
nothing like I expected! I’ve never seen an exception printed in that
format before. Normally they look like this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable
(obviously the error message at the end will vary).
How are you running Python? Are you using an IDE?
In any case, the problem occurs when you try to open a file:
handler = open(file, 'rb')
except that the file argument is not the name of a file, but the names
of many files, in a tuple.
You need to open each file one at a time. Something like:
for filename in list_of_files:
handler = open(file, 'rb')
# ... and then read the PDF and do something with it
You might be able to use the fileinput library instead:
This made me think that i might have a general problem with my idea, I might be missing something in my code. Maybe it helps when I type what I want to achieve with this.
So my goal is: to extract the attached XML files from PDFs. This works with my current code allthough only with single Files. The optimum outcome would be, multiple PDFs to be extracted and for each extracted XML file a unique name to be given to that XML file.(as in, test1.xml, test2.xml etc.)