import arcpy
sourceWorkspace = "C:\\Users\\tx8p90\\Desktop\\Lesson2"
targetProjection = "C:\\Users\\tx8p90\\Desktop\\python excercise data\\Lesson1\\contourlines.shp"
listDataSet = arcpy.ListDatasets(sourceWorkspace)
try:
for x in listDataSet:
outputDataset = sourceWorkspace + "\\projected_" + x
arcpy.Project_management(x, outputDataset, targetProjection)
print "Reprojection successful"
except:
print arcpy.GetMessages()
print "failed"
I have started learning Python for ArcGIS last week and have a simple script to reproject all the datasets in a folder. The script says "syntax error- invalid syntax" but I can't find anything. Can someone please have a look? It seems something very basic but I'm pretty new so I don't see it at the moment. Also running this in ArcGIS prints "failed" right away. And the files are in place in the right folders. I have already checked.
Edit:
Ok just at least the syntax error has disappeared by just writing the code again by removing those 3 dots at the beginning of each line. But still I get "Failed" as output.
targetProjection
argument? According to the help, that is supposed to be a .prj file.