I'm building an ArcGIS toolbox tool from a python script. I'll provide a summary of the tool, the problem I'm having, and the code sample:
Tool Outline:
1. Pre-defined feature classes in an SDE database are merged together. The output of the merge is user-defined.
2. The output from step 1 (merged feature classes) is converted to a file geodatabase table.
3. 2 pre-defined feature classes are converted to a table. The output geodatabase is user-defined.
4. The 3 tables are merged together, with the output being user-defined.
I am getting an error when the tool tries to merge the three tables together. In the toolbox, the parameter is data type = Table and direction = output. My initial thoughts from the error message is that the tool is not recognizing the input tables to the merge, which are the outputs of previous steps. Any and all help is greatly appreciated.
Error message:
Failed at step
Line 94
Failed to execute. Parameters are not valid.
ERROR 000732: Input Datasets: Dataset 'F:\Departments\Public Safety\NARM\2016 Join\NARM_2016_Join';'F:\Departments\Public Safety\NARM\2016 Join\NARM_2016_Join';'F:\Departments\Public Safety\NARM\2016 Join\NARM_2016_Join' does not exist or is not supported
Failed to execute (Merge).
Code:
<SPAN class="comment token"># Import system modules</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">import</SPAN> sys<SPAN class="punctuation token">,</SPAN> traceback<SPAN class="punctuation token">,</SPAN> string
<SPAN class="comment token"># Run geoprocessing tools within Try statement block</SPAN>
<SPAN class="comment token"># 1. Merge point layers together</SPAN>
<SPAN class="comment token"># 2. Convert merged point layers to a table</SPAN>
<SPAN class="comment token"># 3. Convert Parks layer to table</SPAN>
<SPAN class="comment token"># 4. Convert Pipeline layer to table</SPAN>
<SPAN class="comment token"># 5. Merge tables together</SPAN>
<SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token"># Set workspace to SDE user for CCGIS SDE database</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"Database Connections\SDE@CCGIS on NCGSSR04.sde"</SPAN>
<SPAN class="comment token"># Variables for Output</SPAN>
<SPAN class="comment token"># Output for merged point layers</SPAN>
pointLayersMerged <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Output Location for Tables</SPAN>
outputLocation <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Output for table export of merged point layers</SPAN>
<SPAN class="comment token">#pointLayersTable = arcpy.GetParameterAsText(1)</SPAN>
<SPAN class="comment token"># Name for Green_Parks table export</SPAN>
<SPAN class="comment token">#parksTable = arcpy.GetParameterAsText(2)</SPAN>
<SPAN class="comment token"># Name for EOC_Pipeline table export</SPAN>
<SPAN class="comment token">#pipelineTable = arcpy.GetParameterAsText(3)</SPAN>
<SPAN class="comment token"># Name for merged tables</SPAN>
tablesMergeOutput <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Point layers to merge</SPAN>
layersToMerge <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'CCGIS.SDE.Site_Education'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'CCGIS.SDE.EOC_Daycare'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'CCGIS.SDE.Site_HealthMedical'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'CCGIS.SDE.EOC_MHIDD_Facility'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'CCGIS.SDE.Site_GovernmentMilitary'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'CCGIS.SDE.Site_EmergencyResponseLawEnforcement'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'CCGIS.SDE.EOC_AssistedLiving'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'CCGIS.SDE.Site_PublicAttractionLandmarks'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'CCGIS.SDE.EOC_CommunityCenters'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'CCGIS.SDE.EOC_PublicShelters'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'CCGIS.SDE.EOC_SARA'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'CCGIS.SDE.EOC_WasteWaterTreatment'</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token"># 1. Merge point layers</SPAN>
result1 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Merge_management<SPAN class="punctuation token">(</SPAN>layersToMerge<SPAN class="punctuation token">,</SPAN>pointLayersMerged<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Write result message</SPAN>
<SPAN class="keyword token">while</SPAN> result1<SPAN class="punctuation token">.</SPAN>status <SPAN class="operator token"><</SPAN> <SPAN class="number token">4</SPAN><SPAN class="punctuation token">:</SPAN>
time<SPAN class="punctuation token">.</SPAN>sleep<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0.2</SPAN><SPAN class="punctuation token">)</SPAN>
resultValue1 <SPAN class="operator token">=</SPAN> result1<SPAN class="punctuation token">.</SPAN>getMessages<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>resultValue1<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Completed Merging point layers"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># 2. Convert merged point layers to a table</SPAN>
result2 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>TableToDBASE_conversion<SPAN class="punctuation token">(</SPAN>result1<SPAN class="punctuation token">,</SPAN> outputLocation<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Write result message</SPAN>
<SPAN class="keyword token">while</SPAN> result2<SPAN class="punctuation token">.</SPAN>status <SPAN class="operator token"><</SPAN> <SPAN class="number token">4</SPAN><SPAN class="punctuation token">:</SPAN>
time<SPAN class="punctuation token">.</SPAN>sleep<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0.2</SPAN><SPAN class="punctuation token">)</SPAN>
resultValue2 <SPAN class="operator token">=</SPAN> result2<SPAN class="punctuation token">.</SPAN>getMessages<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>resultValue2<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Completed converting Merged Point Layers feature class to a database table"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># 3. Convert Parks layer to table</SPAN>
result3 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>TableToDBASE_conversion<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'CCGIS.SDE.Green_Parks'</SPAN><SPAN class="punctuation token">,</SPAN> outputLocation<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Write result message</SPAN>
<SPAN class="keyword token">while</SPAN> result3<SPAN class="punctuation token">.</SPAN>status <SPAN class="operator token"><</SPAN> <SPAN class="number token">4</SPAN><SPAN class="punctuation token">:</SPAN>
time<SPAN class="punctuation token">.</SPAN>sleep<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0.2</SPAN><SPAN class="punctuation token">)</SPAN>
resultValue3 <SPAN class="operator token">=</SPAN> result3<SPAN class="punctuation token">.</SPAN>getMessages<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>resultValue3<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Completed converting Parks feature class to a database table"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># 4. Convert Pipeline layer to table</SPAN>
result4 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>TableToDBASE_conversion<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'CCGIS.SDE.EOC_PIPELINE'</SPAN><SPAN class="punctuation token">,</SPAN> outputLocation<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Write result message</SPAN>
<SPAN class="keyword token">while</SPAN> result4<SPAN class="punctuation token">.</SPAN>status <SPAN class="operator token"><</SPAN> <SPAN class="number token">4</SPAN><SPAN class="punctuation token">:</SPAN>
time<SPAN class="punctuation token">.</SPAN>sleep<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0.2</SPAN><SPAN class="punctuation token">)</SPAN>
resultValue4 <SPAN class="operator token">=</SPAN> result4<SPAN class="punctuation token">.</SPAN>getMessages<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>resultValue4<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Completed converting Pipeline feature class to a database table"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># 5. Merge tables together</SPAN>
<SPAN class="comment token"># Input tables</SPAN>
tablesMergeInput <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>result2<SPAN class="punctuation token">,</SPAN> result3<SPAN class="punctuation token">,</SPAN> result4<SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token"># Run Merge tool</SPAN>
result5 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Merge_management<SPAN class="punctuation token">(</SPAN>tablesMergeInput<SPAN class="punctuation token">,</SPAN>tablesMergeOutput<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># print result messages</SPAN>
<SPAN class="keyword token">while</SPAN> result5<SPAN class="punctuation token">.</SPAN>status <SPAN class="operator token"><</SPAN> <SPAN class="number token">4</SPAN><SPAN class="punctuation token">:</SPAN>
time<SPAN class="punctuation token">.</SPAN>sleep<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0.2</SPAN><SPAN class="punctuation token">)</SPAN>
resultValue5 <SPAN class="operator token">=</SPAN> result5<SPAN class="punctuation token">.</SPAN>getMessages<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>resultValue5<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Completed merging tables together"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">except</SPAN> Exception<SPAN class="punctuation token">,</SPAN> e<SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token"># If an error occurred, write line number and error message to log</SPAN>
tb <SPAN class="operator token">=</SPAN> sys<SPAN class="punctuation token">.</SPAN>exc_info<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddError<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Failed at step \n"</SPAN> <SPAN class="string token">"Line %i"</SPAN> <SPAN class="operator token">%</SPAN> tb<SPAN class="punctuation token">.</SPAN>tb_lineno<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddError<SPAN class="punctuation token">(</SPAN>e<SPAN class="punctuation token">.</SPAN>message<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>