IOError: [Errno 13] Permission denied:
24,428
You need to change the line
tree = ET.parse(workspace)
to
tree = ET.parse(filename)
because workspace is a directory and the parse method takes a filename.
Author by
Alice Duff
Updated on January 20, 2020Comments
-
Alice Duff over 4 years
I have built this code to specifically identify a load of .XML files and to extract co-ordinates from those files. Here is my code:
from xml.etree import ElementTree as ET import sys, string, os, arcgisscripting gp = arcgisscripting.create(9.3) workspace = "D:/J040083" gp.workspace = workspace for root, dirs, filenames in os.walk(workspace): # returms root, dirs, and files for filename in filenames: filename_split = os.path.splitext(filename) # filename and extensionname (extension in [1]) filename_zero = filename_split[0] extension = str.upper(filename_split[1]) try: first_2_letters = str.upper(filename_zero[0] + filename_zero[1]) except: first_2_letters = "XX" if first_2_letters == "LI" and extension == ".XML": tree = ET.parse(workspace) print tree.find('//{http://www.opengis.net/gml}lowerCorner').text print tree.find('//{http://www.opengis.net/gml}upperCorner').text
I am having trouble with an error:
Message File Name Line Position Traceback <module> D:\J040083\TXT_EXTRACTION.py 32 parse C:\Python25\Lib\xml\etree\ElementTree.py 862 parse C:\Python25\Lib\xml\etree\ElementTree.py 579 IOError: [Errno 13] Permission denied: 'D:/J040083'
I definitely do have access to this folder! I have also tried making new, empty folders and putting just one .xml file in there but i get the same error! Does anyone have any idea what has gone wrong?
-
Alice Duff over 13 yearsI have tried every combinations of \\ or / or even // (just clutching at straws here!)
-
Spaceghost over 13 yearsUse the value of os.filesep to build that path.