Hello,
I have been working on a Python script that will go into multiple sub folders of the main folder and puts all the files with the same name in a list, and then merge them together. Everything works until the Merge_management tool, i get the following error:
Traceback (most recent call last):
File "H:\Python\Practice\Sidra Scripts\test.py", line 31, in <module>
arcpy.Merge_management(fencePoList, outputName)
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 3124, in Merge
raise e
ExecuteError: Failed to execute. Parameters are not valid.
The script is:
import arcpy
import os
from arcpy import env
arcpy.overwriteoutput = 1
inputFolder= "H:\\Python\\Practice\\SampleData\\\Survey_data"
targetFileName= "H:\\Python\\Practice\\SampleData\\Survey_data\\Merged_Posts.shp"
# Create the empty list
fencePoList= []
#try:
for root, dirs, files in os.walk(inputFolder, topdown=True):
for filename in files:
if filename[-6]=="P":
#print os.path.join(root, filename)
fencePosts = str(os.path.join(root, filename))
fencePoList.append(fencePosts)
# Format the list of shapefiles properly for the merge tool
#mergeSHP = '"'+';'.join(fencePoList)+'"'
#print mergeSHP
# Determine the new output feature class path and name
outputName = os.path.join(inputFolder, "Merged_Posts.shp")
#Merging the fence_pole files in all the folders
print "starting merge"
arcpy.Merge_management(fencePoList, outputName)
print "ending merge"
arcpy.AddMessage(arcpy.GetMessages())
#except Exception, ErrorDesc:
#If an error set output boolean parameter "Error" to True.
# arcpy.AddError(str(ErrorDesc))
# row = None
# rows = None
Hope someone can help!
Thanks
Help with Python -->Merge_management
Started by
sidra
, Sep 19 2011 06:18 PM
2 replies to this topic
#1
Posted 19 September 2011 - 06:18 PM
#2
Posted 19 September 2011 - 10:27 PM
Hello
As the error is "Parameters are not valid", i would check what values of fencePoList and outputName are.
i notice you put one extra "\" for the inputFolder (before Survey_data).
it should be
As the error is "Parameters are not valid", i would check what values of fencePoList and outputName are.
i notice you put one extra "\" for the inputFolder (before Survey_data).
it should be
or"H:\\Python\\Practice\\SampleData\\Survey_data" or
Hope this helpsinputFolder= r"H:\Python\Practice\SampleData\Survey_data"
#3
Posted 19 September 2011 - 10:51 PM
I checked my code and i figured out the problem ..my list should only have .shp files, ive modifed my code and its working now 
its funny how sometimes such stupid blunders cause soo much painnn lol
Thanks for your help though, much appreciated
its funny how sometimes such stupid blunders cause soo much painnn lol
Thanks for your help though, much appreciated
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users


Sign In
Create Account
Australia
Back to top
Vietnam








