<?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: Running Multiple Selection and Statistics queries in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/running-multiple-selection-and-statistics-queries/m-p/239530#M18659</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I appreciate you taking time to answer my ignorant questions.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Oct 2012 20:21:13 GMT</pubDate>
    <dc:creator>AnthonyTimpson2</dc:creator>
    <dc:date>2012-10-09T20:21:13Z</dc:date>
    <item>
      <title>Running Multiple Selection and Statistics queries</title>
      <link>https://community.esri.com/t5/python-questions/running-multiple-selection-and-statistics-queries/m-p/239526#M18655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Im just starting to throw myself at a line query and statistics script and am a bit lost on a simple thing. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have sorted out how to select various features and run a statistics export on that selection. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i am running into a problem trying to run multiple selections and append those statistics to the already created output DBF. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
import arcpy
from arcpy import env

env.workspace = "C:/Users/X/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb"
arcpy.SelectLayerByAttribute_management ("Testing", "NEW_SELECTION", " [PRESSURE1] = 300 and [CL_MAOP] = 3 ")
arcpy.Statistics_analysis("Testing", "C:/Users/X/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb", [["Shape_Length", "SUM"]])
arcpy.SelectLayerByAttribute_management ("Testing", "NEW_SELECTION", " [PRESSURE1] = 0 and [CL_MAOP] = 4 ")
arcpy.Statistics_analysis("Testing", "C:/Users/X/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb", [["Shape_Length", "SUM"]])
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My error is &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Runtime error &amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: ERROR 000725: Output Table: Dataset C:\Users\X\Desktop\PNG HCA Program Dev\PNG_Planning_Map.dbf already exists.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;im sure it is something incredibly simple but i just need each query/stats result to be appended to the generated dbf. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Oct 2012 16:28:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-multiple-selection-and-statistics-queries/m-p/239526#M18655</guid>
      <dc:creator>AnthonyTimpson2</dc:creator>
      <dc:date>2012-10-08T16:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple Selection and Statistics queries</title>
      <link>https://community.esri.com/t5/python-questions/running-multiple-selection-and-statistics-queries/m-p/239527#M18656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think it's not possible to directly append rows to table. But you can do this using Append.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Try this code, where first table is created in geodatabase, second table is created in in_memory workspace (temporary) and then appended to first table:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env

env.workspace = "C:/Users/X/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb"
arcpy.SelectLayerByAttribute_management ("Testing", "NEW_SELECTION", " [PRESSURE1] = 300 and [CL_MAOP] = 3 ")
arcpy.Statistics_analysis("Testing", "C:/Users/X/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Stats", [["Shape_Length", "SUM"]])
arcpy.SelectLayerByAttribute_management ("Testing", "NEW_SELECTION", " [PRESSURE1] = 0 and [CL_MAOP] = 4 ")
arcpy.Statistics_analysis("Testing", "in_memory/temp_stats", [["Shape_Length", "SUM"]])

arcpy.Append_management(["in_memory/temp_stats"], "C:/Users/X/Desktop/PNG HCA Program Dev/PNG_Planning_Map.mdb/Stats", "TEST", "", "")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:03:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-multiple-selection-and-statistics-queries/m-p/239527#M18656</guid>
      <dc:creator>MarcinGasior</dc:creator>
      <dc:date>2021-12-11T12:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple Selection and Statistics queries</title>
      <link>https://community.esri.com/t5/python-questions/running-multiple-selection-and-statistics-queries/m-p/239528#M18657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I really appreciate the tip!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am running into a another slight issue. If my query doesnt bring up any results, summary statistics return nothing and No data is appended to the table. is there a way to check that there is no result and have it mash in Zeros instead of nothing?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;While i can probably get around this by simply populating zero for the queries which return nothing, it would be more useful if the output table already contained mention that nothing was found.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2012 19:33:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-multiple-selection-and-statistics-queries/m-p/239528#M18657</guid>
      <dc:creator>AnthonyTimpson2</dc:creator>
      <dc:date>2012-10-09T19:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple Selection and Statistics queries</title>
      <link>https://community.esri.com/t5/python-questions/running-multiple-selection-and-statistics-queries/m-p/239529#M18658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can use the GetCount_management tool that returns the number of rows in a table, featureclass, or layer.&amp;nbsp; Use that value in an if, else statement to execute different processes based on there either being a count &amp;gt; 0 or count = 0.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2012 20:17:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-multiple-selection-and-statistics-queries/m-p/239529#M18658</guid>
      <dc:creator>ChristopherThompson</dc:creator>
      <dc:date>2012-10-09T20:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple Selection and Statistics queries</title>
      <link>https://community.esri.com/t5/python-questions/running-multiple-selection-and-statistics-queries/m-p/239530#M18659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I appreciate you taking time to answer my ignorant questions.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2012 20:21:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-multiple-selection-and-statistics-queries/m-p/239530#M18659</guid>
      <dc:creator>AnthonyTimpson2</dc:creator>
      <dc:date>2012-10-09T20:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Running Multiple Selection and Statistics queries</title>
      <link>https://community.esri.com/t5/python-questions/running-multiple-selection-and-statistics-queries/m-p/239531#M18660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;"Ignorant" is sort of a harsh term... even if its an honest ignorance.. you're obviously moving in the right direction.. the problem with learning programming languages is the same as with any other language.. the vocabulary.&amp;nbsp; You might know how to put together the sentence, if you just knew the words &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp; Don't be shy about asking - it can save you hours or days sometimes so ask away!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Oct 2012 20:38:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/running-multiple-selection-and-statistics-queries/m-p/239531#M18660</guid>
      <dc:creator>ChristopherThompson</dc:creator>
      <dc:date>2012-10-09T20:38:51Z</dc:date>
    </item>
  </channel>
</rss>

