I am working on Exercise 6 challenge 2 when I put in the attached code it generates a Error 000260 Error. I have run the code line by line and it is fine until it gets to
arcpy.Copy_management (fc, "C:\EsriPress\Python\Data\Exercise06\newstudy.gdb" + fc) this is the last line of the code. It is unable to copy the feature classes. I will attach the code that I am using. I was wondering if I would be able to get some help on this. This is my first time asking a question on Geonet.
This :
arcpy.Copy_management (fc, "C:\EsriPress\Python\Data\Exercise06\newstudy.gdb" + fc)
Probably need a "\" in the path between the ".gdb" and the fc.
Like
arcpy.Copy_management (fc, r"C:\EsriPress\Python\Data\Exercise06\newstudy.gdb\" + fc)
Note the use of the "r" in front of this path. Python then does not try to "interpret" text, it is raw format. For example text like "\n" is a newline.
Better still use os.path.join() to join paths and outputs.
Hi Stephan,
Welcome to Geonet first of all. In the future if you have a small amount of code that you need help with, its easier for you to post it directly in your question (See https://community.esri.com/people/curtvprice/blog/2014/09/25/posting-code-blocks-in-the-new-geonet?s... for examples on how), since people are not always able/comfortable to open zip files from the internet. Also if you have an error code, please post the error code and error message to give more detail on the problem (in this case it was probably something about unable to write features or invalid path which is relevant information).
As to your error, I would use some print statements to determine whether your output for the copy tool is what you think it is, you may be missing something needed for the full file path. Also I would recommend using the os module for creating file paths instead of just concatenating paths and file names.
https://docs.python.org/2/library/os.path.html
Example of its use from the ListFeatureClasses help.
http://pro.arcgis.com/en/pro-app/arcpy/functions/listfeatureclasses.htm
Edit: I see Neil answered you more directly, but I would strongly recommend using print statements for debugging to make sure your inputs are correct when such errors occur.