<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Merge Script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/merge-script/m-p/62275#M4998</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does this python script look correct for a merge?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Import arcpy module import arcpy, sys, traceback arcpy.env.overwriteOutput = True from os import path as p&amp;nbsp;&amp;nbsp; # Set Workspace arcpy.env.workspace = r"G:\ChrisGIS\PS_Steelhead\Archive"&amp;nbsp; # Set Variables. "out" will be our output variable. Inside the "Try" loop we search all workspaces # for the Feature Class we are interested in. This list of feature classes is set to listFCS&amp;nbsp; out = r"G:\ChrisGIS\PS_Steelhead\Scratch"&amp;nbsp; for ws in arcpy.Listworkspaces("*", "FileGDB"):&amp;nbsp; arcpy.env.workspace = ws&amp;nbsp; print '\n\Searching in %s\n\n' %ws&amp;nbsp; listFCS = arcpy.ListFeatureClasses("*_NWIFC_STHD")&amp;nbsp; # Now Merge all Feature Classes and export to the Output&amp;nbsp; arcpy.Merge_management(listFCS, os.path.join(out, "Merged_HUC8_STHD") print "Done"&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Feb 2013 03:02:35 GMT</pubDate>
    <dc:creator>ChristopherClark1</dc:creator>
    <dc:date>2013-02-14T03:02:35Z</dc:date>
    <item>
      <title>Merge Script</title>
      <link>https://community.esri.com/t5/python-questions/merge-script/m-p/62275#M4998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does this python script look correct for a merge?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Import arcpy module import arcpy, sys, traceback arcpy.env.overwriteOutput = True from os import path as p&amp;nbsp;&amp;nbsp; # Set Workspace arcpy.env.workspace = r"G:\ChrisGIS\PS_Steelhead\Archive"&amp;nbsp; # Set Variables. "out" will be our output variable. Inside the "Try" loop we search all workspaces # for the Feature Class we are interested in. This list of feature classes is set to listFCS&amp;nbsp; out = r"G:\ChrisGIS\PS_Steelhead\Scratch"&amp;nbsp; for ws in arcpy.Listworkspaces("*", "FileGDB"):&amp;nbsp; arcpy.env.workspace = ws&amp;nbsp; print '\n\Searching in %s\n\n' %ws&amp;nbsp; listFCS = arcpy.ListFeatureClasses("*_NWIFC_STHD")&amp;nbsp; # Now Merge all Feature Classes and export to the Output&amp;nbsp; arcpy.Merge_management(listFCS, os.path.join(out, "Merged_HUC8_STHD") print "Done"&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2013 03:02:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/merge-script/m-p/62275#M4998</guid>
      <dc:creator>ChristopherClark1</dc:creator>
      <dc:date>2013-02-14T03:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Script</title>
      <link>https://community.esri.com/t5/python-questions/merge-script/m-p/62276#M4999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It's not clear what you want to do. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I suppose you want to merge feature classes from many geodatabases. If so, you have to collect all feature classes names with full path in one list and use this list in Merge.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's how code can look like (remember to create geodatabase in your scratch folder first):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, sys, os, traceback arcpy.env.overwriteOutput = 1&amp;nbsp; # Set Workspace arcpy.env.workspace = r"G:\ChrisGIS\PS_Steelhead\Archive"&amp;nbsp; # Set Variables. "out" will be our output variable. Inside the "Try" loop we search all workspaces # for the Feature Class we are interested in. This list of feature classes is set to listFCS&amp;nbsp; out = r"G:\ChrisGIS\PS_Steelhead\Scratch\Scratch.gdb"&amp;nbsp;&amp;nbsp; # list for all feature classes from different GDBs to merge fcToMerge = []&amp;nbsp; for ws in arcpy.ListWorkspaces("*", "FileGDB"): &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = ws &amp;nbsp;&amp;nbsp;&amp;nbsp; print '\n\Searching in %s\n\n' %ws &amp;nbsp;&amp;nbsp;&amp;nbsp; listFCS = arcpy.ListFeatureClasses("*_NWIFC_STHD")&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # create a list with full pathes to feature classes &amp;nbsp;&amp;nbsp;&amp;nbsp; listFCsFullPath =[] &amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in listFCS: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; listFCsFullPath.append(os.path.join(ws, fc))&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; fcToMerge += listFCsFullPath&amp;nbsp; # Now Merge all Feature Classes and export to the Output arcpy.Merge_management(fcToMerge, os.path.join(out, "Merged_HUC8_STHD")) print "Done"&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2013 07:30:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/merge-script/m-p/62276#M4999</guid>
      <dc:creator>MarcinGasior</dc:creator>
      <dc:date>2013-02-14T07:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Script</title>
      <link>https://community.esri.com/t5/python-questions/merge-script/m-p/62277#M5000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I modified the included script, but I'm receiving an error &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute. Parameters not valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Error 000735: Input Datasets: Value is required&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute(merge)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to combine all the fc in each gdb, in the topo folder, into a single gdb.&amp;nbsp; Each gdb has a feature dataset "lts" that contains all the fc (in case it matters). I'm not sure why fcToMerge isn't a valid input. Any help would be appreciated- thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 16:28:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/merge-script/m-p/62277#M5000</guid>
      <dc:creator>MelissaBennett</dc:creator>
      <dc:date>2014-04-10T16:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: Merge Script</title>
      <link>https://community.esri.com/t5/python-questions/merge-script/m-p/62278#M5001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I believe it would be because you are not going into each feature dataset and then listing feature classes.&amp;nbsp; The example given assumes your feature classes are directly in the gdb, not in a feature dataset in a gdb.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;you would need to use arcpy.ListDatasets in there to fix&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

import arcpy, sys, os, traceback
arcpy.env.overwriteOutput = 1

# Set Workspace
arcpy.env.workspace = r"G:\ChrisGIS\PS_Steelhead\Archive"

# Set Variables. "out" will be our output variable. Inside the "Try" loop we search all workspaces
# for the Feature Class we are interested in. This list of feature classes is set to listFCS

out = r"G:\ChrisGIS\PS_Steelhead\Scratch\Scratch.gdb"


# list for all feature classes from different GDBs to merge
fcToMerge = []

for ws in arcpy.ListWorkspaces("*", "FileGDB"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = ws
&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\n\Searching in %s\n\n' %ws
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fd in&amp;nbsp; arcpy.ListDatasets("*", "Feature")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = fd
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print '\n\Searching in %s\n\n' %fd
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; listFCS = arcpy.ListFeatureClasses("*_NWIFC_STHD")

&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # create a list with full pathes to feature classes
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; listFCsFullPath =[]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in listFCS:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; listFCsFullPath.append(os.path.join(ws, fc))

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcToMerge += listFCsFullPath

# Now Merge all Feature Classes and export to the Output
arcpy.Merge_management(fcToMerge, os.path.join(out, "Merged_HUC8_STHD"))

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: I copied the old code from m.gasior and edited that one to work, so you will need to rework it from what I did for yours, but that should fix it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:22:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/merge-script/m-p/62278#M5001</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2021-12-10T22:22:37Z</dc:date>
    </item>
  </channel>
</rss>

