<?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 Re: Using Recursive Iterator outputs as Inputs to Tools in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-recursive-iterator-outputs-as-inputs-to/m-p/71982#M5929</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What's the error message it's returning? Have you tried it without the workspace tweaking?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for dirPath, dirNames, fileNames in os.walk(rootDir):#, topdown=False):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for file in fileNames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if fnmatch.fnmatch(file, "*100110.shp"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shpname = os.path.join(dirPath, file)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Buffer_analysis(shpname, r"FILEPATHGOESHERE", 1000)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 22:47:19 GMT</pubDate>
    <dc:creator>JasonScheirer</dc:creator>
    <dc:date>2021-12-10T22:47:19Z</dc:date>
    <item>
      <title>Using Recursive Iterator outputs as Inputs to Tools</title>
      <link>https://community.esri.com/t5/python-questions/using-recursive-iterator-outputs-as-inputs-to/m-p/71981#M5928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I couldnt get two iterators to work through modelbuilder, so I am trying Python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Being a total newbie to Python, I was able to set up a loop that gets each shapefile in multiple directories using a wildcard (it is printing each shapefile with print command), but I don't know where to go from here.&amp;nbsp; I want to be able to use each shapefile to be used as an input feature.&amp;nbsp; And then going to do the same thing for other shapefiles based on a different wildcard and for the second tool input (e.g clip, erase, identify feature).&amp;nbsp; How will I go about passing along each file during the loop for the input feature and the other feature at concurrent times? eg. first returned shapefile in one loop will be input feature and first returned shapefile in second loop will be..say an erase feature&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyways, for a first step, I was just testing the Buffer tool to see if one recursive loop would work, but it doesn't like &lt;/SPAN&gt;&lt;STRONG&gt;file&lt;/STRONG&gt;&lt;SPAN&gt; as the input parameter. Clearly that must be the wrong parameter.&amp;nbsp; What do I need to do here?&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, os, fnmatch #for wildcards from arcpy import env&amp;nbsp; rootDir = r"FILEPATH_IS_HERE"&amp;nbsp; for dirPath, dirNames, fileNames in os.walk(rootDir):#, topdown=False): &amp;nbsp;&amp;nbsp;&amp;nbsp; for file in fileNames: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if fnmatch.fnmatch(file, "*100110.shp")== True: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print os.path.join(dirPath, file) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; env.workspace = os.path.join(dirPath, file) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Buffer_analysis(file, r"FILEPATHGOESHERE", 1000)&amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp; print "No other matching 100110's"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for any help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 22:36:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-recursive-iterator-outputs-as-inputs-to/m-p/71981#M5928</guid>
      <dc:creator>BrianDudek</dc:creator>
      <dc:date>2012-07-11T22:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using Recursive Iterator outputs as Inputs to Tools</title>
      <link>https://community.esri.com/t5/python-questions/using-recursive-iterator-outputs-as-inputs-to/m-p/71982#M5929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What's the error message it's returning? Have you tried it without the workspace tweaking?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for dirPath, dirNames, fileNames in os.walk(rootDir):#, topdown=False):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for file in fileNames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if fnmatch.fnmatch(file, "*100110.shp"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shpname = os.path.join(dirPath, file)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Buffer_analysis(shpname, r"FILEPATHGOESHERE", 1000)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:47:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-recursive-iterator-outputs-as-inputs-to/m-p/71982#M5929</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2021-12-10T22:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using Recursive Iterator outputs as Inputs to Tools</title>
      <link>https://community.esri.com/t5/python-questions/using-recursive-iterator-outputs-as-inputs-to/m-p/71983#M5930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;What's the error message it's returning? Have you tried it without the workspace tweaking? &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&amp;nbsp; I actually just had to remove file as a parameter from the env.workspace line.&amp;nbsp; So I got that settled now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Curious how I would go about exporting the output files to a lower level directory (with a specific name-have to use another wildcard I presume) from where the input file exists.&amp;nbsp;&amp;nbsp; Right now it exports the output feature in the directory of the input feature.&amp;nbsp; &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//004000000008000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//004000000008000000.htm&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp; This link indicates to use os.path.dirname(input), but how would I set it up with the existing filename loop I already have?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jul 2012 21:25:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-recursive-iterator-outputs-as-inputs-to/m-p/71983#M5930</guid>
      <dc:creator>BrianDudek</dc:creator>
      <dc:date>2012-07-12T21:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using Recursive Iterator outputs as Inputs to Tools</title>
      <link>https://community.esri.com/t5/python-questions/using-recursive-iterator-outputs-as-inputs-to/m-p/71984#M5931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Not sure if I understand you right but here is something you can try.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You will have to first create "outputFolder" either programmatically or manually.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, os, fnmatch #for wildcards from arcpy import env&amp;nbsp; rootDir = r"FILEPATH_IS_HERE" ourDirName = "outputFolder" buffShape = "outputBuffer.shp"&amp;nbsp; for dirPath, dirNames, fileNames in os.walk(rootDir):#, topdown=False): &amp;nbsp;&amp;nbsp;&amp;nbsp; for file in fileNames: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if fnmatch.fnmatch(file, "*100110.shp")== True: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print os.path.join(dirPath, file) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; env.workspace = os.path.join(dirPath, file) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Buffer_analysis(file, rootDir + os.sep + outDirName + os.sep + buffShape, 1000)&amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp; print "No other matching 100110's"&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jul 2012 23:30:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-recursive-iterator-outputs-as-inputs-to/m-p/71984#M5931</guid>
      <dc:creator>SolomonPulapkura</dc:creator>
      <dc:date>2012-07-12T23:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Using Recursive Iterator outputs as Inputs to Tools</title>
      <link>https://community.esri.com/t5/python-questions/using-recursive-iterator-outputs-as-inputs-to/m-p/71985#M5932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you it was os.sep that I was looking for. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also can anyone give me an indication why "Parameters are not valid" on the line of arcpy.merge_managment(vt, featureOut)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just trying to do a merge of feature classes picked up from multiple directories with certain characters in the filename.&amp;nbsp; Clearly something is wrong with the list.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os, fnmatch #fnmatch for wildcards
from arcpy import env

rootDir = XXXXX
vt = arcpy.CreateObject("ValueTable")

for dirPath, dirNames, fileNames in os.walk(rootDir):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for file in fileNames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if fnmatch.fnmatch(file, "*AddedNew*.shp")== True: #iterates for files with AddedNew in name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; env.workspace = os.path.join(dirPath)&amp;nbsp; #tells where to look for input feature
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shps = arcpy.ListFeatureClasses("*", "Polygon")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print shps
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for shp in shps:
&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;&amp;nbsp;&amp;nbsp; vt.addRow(shp)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; featureOut = os.path.dirname(dirPath) + "Statewide_NewCoverage" # Finds area of beginning iteratiom + Name of outputfeatureclass
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Merge_management(vt,featureOut)
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Merge New Coverage files has failed"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT: I got it working using another example without using arcpy.ListFeatureClasses, but by just populating filepaths into a [] with the append tool.&amp;nbsp; Then I feed that into the merge_management.&amp;nbsp; However, the problem is that it exports a shapefile for each merger.&amp;nbsp; For instance, it exports first file by itself, than the second shapefile merged with the first, then the third shapefile merged with first and second.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:47:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-recursive-iterator-outputs-as-inputs-to/m-p/71985#M5932</guid>
      <dc:creator>BrianDudek</dc:creator>
      <dc:date>2021-12-10T22:47:21Z</dc:date>
    </item>
  </channel>
</rss>

