Why would this simple buffer script fail?

627
3
Jump to solution
04-17-2012 09:11 AM
PeterPeng
New Contributor II
(the script was straight from the ESRI python tutorial)

>>> #Buffer the roads feature class for each distance in the distance list ... import arcpy ... arcpy.env.workspace = r"C:\PETER PENG\ppTests.gdb" ... fc = "TestApr17" ... distanceList= ["100 meters", "200 meters", "400 meters"] ... #loop thru ea distance in the distanceList ... for dist in distanceList: ...     outName = fc+"_"+dist ...     arcpy.Buffer_analysis(fc, outName, dist) ... print "Finished buffering" ...  Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 000210: Cannot create output C:\PETER PENG\ppTests.gdb\TestApr17_100 meters Failed to execute (Buffer).  >>> 




- Tried the non-python method: Buffer tool in toolbox, worked!
- Tried different file path names, taking away "_". Does Python not accept " "(space)? I thought raw data was fine?
- Message Log attached
- Have no idea how to get this simple script to work, any help appreciated!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ChrisSnyder
Regular Contributor III
Don't use spaces in your dataset names.


Using this line should fix your problem...
outName = fc+"_"+dist.replace(" ", "_")

View solution in original post

0 Kudos
3 Replies
ChrisSnyder
Regular Contributor III
Don't use spaces in your dataset names.


Using this line should fix your problem...
outName = fc+"_"+dist.replace(" ", "_")
0 Kudos
ChrisSnyder
Regular Contributor III
0 Kudos
PeterPeng
New Contributor II
Spaces was my problem, thanks!
0 Kudos