Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Trouble with 'Python for Everyone' course

$
0
0
Hi, I'm doing the 'Python for Everyone' course from ESRI http://training.esri.com/Courses/Pyt...0_1/player.cfm and my script isn't working.

It says that
Code:

path = r"C:\Student\PythEveryone10_1\Creating Scripts\BismarckUpd.txt"
file = open(path, 'w')

will create and open a text file, however, when I run the script I get these errors returned:

"Traceback (most recent call last):
File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
exec codeObject in __main__.__dict__
File "C:\Student\PythEveryone10_1\CreatingScripts\BismarckShapefiles.py", line 11, in <module>
file = open(path, 'w')
IOError: [Errno 2] No such file or directory: 'C:\\Student\\PythEveryone10_1\\Creating Scripts\\BismarckUpd.txt'
"

Here is the whole script.
Code:

#Assign variables to the shapefiles
park = "nd_park520.shp"
school = "ND_schools454.shp"
sewer = "nd_sew454.shp"

#Create a list of shapefile variables
shapeList = [park, school, sewer]

#Create and open new text file for updated shapefiles
path = r"C:\Student\PythEveryone10_1\Creating Scripts\BismarckUpd.txt"
file = open(path, 'w')

#Update the names of the shapefiles in shapefile list
for shp in shapeList:
    print shp
    shp = shp.replace("nd", "ND")
    print shp
    file.write(shp +"\n")

file.close()

If you could help me understand what I'm doing wrong or where something went wrong I'd appreciate it, thank you.

Viewing all articles
Browse latest Browse all 2485

Trending Articles