I read all the files in the directory with the following lines of code:
os.chdir(path)
extension = 'xml'
all_filenames = [i for i in glob('*.{}'.format(extension))]
Then if I try to parse a file with the name starting with _ I get the following error:
FileNotFoundError: [Errno 2] No such file or directory: '_a-0000e3c4-17e8-8000-9ba2-011c48011c48_6736348.xml'
The Code for parsing the files:
import xml.etree.ElementTree as et
tree = et.parse(all_filenames[252])
root = tree.getroot()
print(f"name: {root[1][0].text}")
print(f"UUID: {root[1][1].text}")
In the example the index [252] corresponds to a random file in the directory that starts with a _
Does anyone knows how can I read files starting with _?
Thanks for the help
UPDATE
Also this does not work:
with open(all_filenames[252]) as file:
data = file.read()
I am running python in a windows environment.
Python 3.7.4 installed with anaconda distribution
Windows 10 (1903)
UPDATE 2
Problem might be related to windows, running this code in cmd will also fail:
REN "_undescorearchive.xml" "undescorearchive.xml"