0

I want to read different XML files to do the parsing later. My code is below, but I got following exception:

IsADirectoryError: [Errno 21] Is a directory: '.ipynb_checkpoints'

This is my code:

from os import listdir
for file in listdir():
    print(file)
    xmlTree = parse(file)
    elemList = []

How can I fix this error?

Artyom Vancyan
  • 5,029
  • 3
  • 12
  • 34
charles
  • 209
  • 3
  • 10
  • Does this answer your question? [How to identify whether a file is normal file or directory using python](https://stackoverflow.com/questions/955941/how-to-identify-whether-a-file-is-normal-file-or-directory-using-python) – Brian61354270 Mar 04 '20 at 03:07

1 Answers1

0

I post the answer if someone else got my error.

for filename in os.listdir(path):
    if not filename.endswith('.xml'): continue
    fullname = os.path.join(path, filename)
    xmlTree = parse(filename)
charles
  • 209
  • 3
  • 10