<?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: Recognise whether Python Toolbox tool is used in batch processing mode in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/recognise-whether-python-toolbox-tool-is-used-in/m-p/1250251#M66611</link>
    <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-questions/python-tool-box-batch-process-not-working/m-p/1220036#M65792" target="_blank"&gt;Python tool box batch process not working. - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;has some discussion and the limitations are mentioned in the help topic&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/basics/batch-geoprocessing.htm" target="_blank"&gt;Batch geoprocessing—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 22 Jan 2023 14:34:14 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2023-01-22T14:34:14Z</dc:date>
    <item>
      <title>Recognise whether Python Toolbox tool is used in batch processing mode</title>
      <link>https://community.esri.com/t5/python-questions/recognise-whether-python-toolbox-tool-is-used-in/m-p/1250249#M66610</link>
      <description>&lt;P&gt;I have a Python Toolbox tool that extracts values from a raster to a .csv table.&lt;BR /&gt;Now I want to enable the user to apply the tool to multiple rasters in a batch process and to combine the results in a single .csv table.&lt;/P&gt;&lt;P&gt;Is there a way to find out whether the tool is run in batch mode from within that tool?&lt;BR /&gt;(I thought about checking whether the tool is in batch mode and, if true, to append the existing output table if it was initially created during an earlier run of the tool during that batch process.)&lt;BR /&gt;Is this even possible and, if it is, how?&lt;/P&gt;</description>
      <pubDate>Sun, 22 Jan 2023 14:21:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/recognise-whether-python-toolbox-tool-is-used-in/m-p/1250249#M66610</guid>
      <dc:creator>Manu</dc:creator>
      <dc:date>2023-01-22T14:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Recognise whether Python Toolbox tool is used in batch processing mode</title>
      <link>https://community.esri.com/t5/python-questions/recognise-whether-python-toolbox-tool-is-used-in/m-p/1250251#M66611</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-questions/python-tool-box-batch-process-not-working/m-p/1220036#M65792" target="_blank"&gt;Python tool box batch process not working. - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;has some discussion and the limitations are mentioned in the help topic&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/basics/batch-geoprocessing.htm" target="_blank"&gt;Batch geoprocessing—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Jan 2023 14:34:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/recognise-whether-python-toolbox-tool-is-used-in/m-p/1250251#M66611</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-01-22T14:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Recognise whether Python Toolbox tool is used in batch processing mode</title>
      <link>https://community.esri.com/t5/python-questions/recognise-whether-python-toolbox-tool-is-used-in/m-p/1250293#M66612</link>
      <description>&lt;P&gt;Hmm, the way I see it, there are at least 2 options.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Option 1: Don't use batching, use multivalue parameters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;class SomeTool:
    label = "SomeTool"
    def getParameterInfo(self):
        return [
            arcpy.Parameter(name="raster", displayName="Raster", datatype="DERasterDataset", parameterType="Required", direction="Input", multiValue=True),
            arcpy.Parameter(name="csv", displayName="Output CSV", datatype="DEFile", parameterType="Required", direction="Output"),
            ]

    def execute(self, parameters, messages):
        par = {p.name: p for p in parameters}
        rasters = str(par["raster"].value).split(";")
        with open(str(par["csv"].value), "w") as csv_file:
            csv_file.write("Header line\n")
            for raster in rasters:
                # extract and write for each raster
                csv_file.write(str(raster) + "\n")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1674458221425.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/60952i3BCA568BF82E962B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1674458221425.png" alt="JohannesLindner_1-1674458221425.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Option 2, if you really want to batch: Check if the output csv exists. If not, create it and write the header line. Then use append mode to write the extracted raster values.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 07:17:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/recognise-whether-python-toolbox-tool-is-used-in/m-p/1250293#M66612</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-01-23T07:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: Recognise whether Python Toolbox tool is used in batch processing mode</title>
      <link>https://community.esri.com/t5/python-questions/recognise-whether-python-toolbox-tool-is-used-in/m-p/1250323#M66613</link>
      <description>&lt;P&gt;Thanks, I didn't know about the multiValue option. This is exactly what I needed!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 10:34:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/recognise-whether-python-toolbox-tool-is-used-in/m-p/1250323#M66613</guid>
      <dc:creator>Manu</dc:creator>
      <dc:date>2023-01-23T10:34:23Z</dc:date>
    </item>
  </channel>
</rss>

