<?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 Help with Python Code in Python Snippets Questions</title>
    <link>https://community.esri.com/t5/python-snippets-questions/help-with-python-code/m-p/835010#M438</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to create a script that will traverse through a giant attribute table (comprised of the records of 68 polygons), and total up the values in a particular field for features within each polygon.&amp;nbsp; I want the script to go through the table, look for polygon 1 records, add all values in the "Grand_Tota" field, the move on to looking for all records that comprise polygon 2, and so on.&lt;/P&gt;&lt;P&gt;I haven't used Lists too often so perhaps my problem lies there.&lt;/P&gt;&lt;P&gt;When I run the code now, it just spits keeps spitting out the first total (5).&lt;/P&gt;&lt;P&gt;Each polygon feature is weirdly named "Location X : 0 - 5" where X is the loc number.&lt;/P&gt;&lt;P&gt;#======================================================================&lt;BR /&gt;import arcpy&lt;/P&gt;&lt;P&gt;fc = "C:\Users\surbemi\Desktop\New folder\Export_Output.shp"&lt;BR /&gt;field = "Grand_Tota"&lt;BR /&gt;sCursor = arcpy.SearchCursor(fc)&lt;BR /&gt;loc = 1&lt;BR /&gt;polyName = "Name"&amp;nbsp;&amp;nbsp; # Names are formatted ("Location X : 0 - 5") where X = loc&lt;BR /&gt;sum = 0&lt;BR /&gt;total = []&lt;/P&gt;&lt;P&gt;while loc &amp;lt; 21:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in sCursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.getValue(polyName) == "Location " + str(loc) + " : 0 - 5":&lt;BR /&gt;&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; i = row.getValue(field)&lt;BR /&gt;&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; sum = sum + i&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; total.append(sum)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Location " + str(loc) + " Total: " + str(int(total[loc-1]))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum = 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; loc = loc + 1&lt;/P&gt;&lt;P&gt;#======================================================================&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 31 Jul 2017 16:19:41 GMT</pubDate>
    <dc:creator>MickSurber</dc:creator>
    <dc:date>2017-07-31T16:19:41Z</dc:date>
    <item>
      <title>Help with Python Code</title>
      <link>https://community.esri.com/t5/python-snippets-questions/help-with-python-code/m-p/835010#M438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to create a script that will traverse through a giant attribute table (comprised of the records of 68 polygons), and total up the values in a particular field for features within each polygon.&amp;nbsp; I want the script to go through the table, look for polygon 1 records, add all values in the "Grand_Tota" field, the move on to looking for all records that comprise polygon 2, and so on.&lt;/P&gt;&lt;P&gt;I haven't used Lists too often so perhaps my problem lies there.&lt;/P&gt;&lt;P&gt;When I run the code now, it just spits keeps spitting out the first total (5).&lt;/P&gt;&lt;P&gt;Each polygon feature is weirdly named "Location X : 0 - 5" where X is the loc number.&lt;/P&gt;&lt;P&gt;#======================================================================&lt;BR /&gt;import arcpy&lt;/P&gt;&lt;P&gt;fc = "C:\Users\surbemi\Desktop\New folder\Export_Output.shp"&lt;BR /&gt;field = "Grand_Tota"&lt;BR /&gt;sCursor = arcpy.SearchCursor(fc)&lt;BR /&gt;loc = 1&lt;BR /&gt;polyName = "Name"&amp;nbsp;&amp;nbsp; # Names are formatted ("Location X : 0 - 5") where X = loc&lt;BR /&gt;sum = 0&lt;BR /&gt;total = []&lt;/P&gt;&lt;P&gt;while loc &amp;lt; 21:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in sCursor:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row.getValue(polyName) == "Location " + str(loc) + " : 0 - 5":&lt;BR /&gt;&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; i = row.getValue(field)&lt;BR /&gt;&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; sum = sum + i&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; total.append(sum)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Location " + str(loc) + " Total: " + str(int(total[loc-1]))&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum = 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; loc = loc + 1&lt;/P&gt;&lt;P&gt;#======================================================================&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Jul 2017 16:19:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/help-with-python-code/m-p/835010#M438</guid>
      <dc:creator>MickSurber</dc:creator>
      <dc:date>2017-07-31T16:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Python Code</title>
      <link>https://community.esri.com/t5/python-snippets-questions/help-with-python-code/m-p/835011#M439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;tagging &lt;A href="https://community.esri.com/space/2145"&gt;Python&lt;/A&gt;‌&amp;nbsp; for more exposure&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this a script you need to do for a class?&amp;nbsp; If not, there may be easier ways to do this that do not require a cursor or even a python script.&amp;nbsp; But if you do need a cursor/script, you may want to look at the .da module for your cursors &lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/what-is-the-data-access-module-.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/what-is-the-data-access-module-.htm"&gt;What is the data access module?—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Jul 2017 17:21:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/help-with-python-code/m-p/835011#M439</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2017-07-31T17:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Python Code</title>
      <link>https://community.esri.com/t5/python-snippets-questions/help-with-python-code/m-p/835012#M440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the speedy reply Rebecca !&amp;nbsp; It's for a work problem and using a cursor to check each row of an attribute table is the only way I know how .... I will review the link you provided.&amp;nbsp; Thanks very much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Jul 2017 17:29:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/help-with-python-code/m-p/835012#M440</guid>
      <dc:creator>MickSurber</dc:creator>
      <dc:date>2017-07-31T17:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Python Code</title>
      <link>https://community.esri.com/t5/python-snippets-questions/help-with-python-code/m-p/835013#M441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;before you start coding, make sure &lt;STRONG&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/analysis-toolbox/summary-statistics.htm"&gt;Summary Statistics&lt;/A&gt;&lt;/STRONG&gt; ... doesn't do what you want&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Jul 2017 17:35:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/help-with-python-code/m-p/835013#M441</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-07-31T17:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Python Code</title>
      <link>https://community.esri.com/t5/python-snippets-questions/help-with-python-code/m-p/835014#M442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks very much&amp;nbsp;for your input Dan.&amp;nbsp; I review the content of your link.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Jul 2017 17:43:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/help-with-python-code/m-p/835014#M442</guid>
      <dc:creator>MickSurber</dc:creator>
      <dc:date>2017-07-31T17:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Python Code</title>
      <link>https://community.esri.com/t5/python-snippets-questions/help-with-python-code/m-p/835015#M443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't forget to add an 'r' in front of your path strings.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;fc = &lt;STRONG&gt;r&lt;/STRONG&gt;"C:\Users\surbemi\Desktop\New folder\Export_Output.shp"&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Jul 2017 18:34:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/help-with-python-code/m-p/835015#M443</guid>
      <dc:creator>MitchHolley1</dc:creator>
      <dc:date>2017-07-31T18:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Python Code</title>
      <link>https://community.esri.com/t5/python-snippets-questions/help-with-python-code/m-p/835016#M444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reminder Mitch.&amp;nbsp; I do often forget that !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Jul 2017 18:36:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/help-with-python-code/m-p/835016#M444</guid>
      <dc:creator>MickSurber</dc:creator>
      <dc:date>2017-07-31T18:36:51Z</dc:date>
    </item>
  </channel>
</rss>

