<?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: Adding sequential number according to change value of next field using ArcPy in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/adding-sequential-number-according-to-change-value/m-p/678378#M22533</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Darren,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the code I used for filling the Field 2.&amp;nbsp; (I have ArcGIS 10.3.1 by the way)&lt;/P&gt;&lt;P&gt;Source:&amp;nbsp; &lt;A href="http://support.esri.com/fr/knowledgebase/techarticles/detail/38517" title="http://support.esri.com/fr/knowledgebase/techarticles/detail/38517"&gt;38517 - Create sequential numbers in a field using Python in the Field Calculator&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pre-Logic Script Code:&lt;/P&gt;&lt;P&gt;rec=0 &lt;/P&gt;&lt;P&gt;def autoIncrement(): &lt;/P&gt;&lt;P&gt; global rec &lt;/P&gt;&lt;P&gt; pStart = 1&amp;nbsp; &lt;/P&gt;&lt;P&gt; pInterval = 1 &lt;/P&gt;&lt;P&gt; if (rec == 0):&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; rec = pStart&amp;nbsp; &lt;/P&gt;&lt;P&gt; else:&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; rec += pInterval&amp;nbsp; &lt;/P&gt;&lt;P&gt; return rec&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression:&lt;/P&gt;&lt;P&gt;autoIncrement()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a vague idea of having double loop of entering sequential number to Field 3 as number changes in Field 1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rec=0&lt;/P&gt;&lt;P&gt;field1 = 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def autoIncrement(): &lt;/P&gt;&lt;P&gt; global rec &lt;/P&gt;&lt;P&gt; global field 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP1 field1 +=1 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOOP2 rec += 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END LOOP2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return rec&lt;/P&gt;&lt;P&gt;END LOOP1 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I appreciate your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 Mar 2016 22:14:43 GMT</pubDate>
    <dc:creator>AngelaKim2</dc:creator>
    <dc:date>2016-03-15T22:14:43Z</dc:date>
    <item>
      <title>Adding sequential number according to change value of next field using ArcPy</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-sequential-number-according-to-change-value/m-p/678375#M22530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My goal is to create and fill data like (Field 3) from (Field 1) using the Field Calculator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was able to assigning sequential numbers using ArcPy code out there, but it gave me results of (Field 2).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume I need double loop to achieve the result of (Field 3), but the problem is I'm not familiar with ArcPy at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be great if you help me out with ArcPy or even point the sample code I can look at.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AK&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #c6c6c6; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;Field 1&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;Field 2&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: left; background-color: #f2f2f2; color: #505050; padding: 6px;" valign="middle"&gt;&lt;STRONG&gt;Field 3&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;5&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;6&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;7&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;8&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;9&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 6px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;10&lt;/TD&gt;&lt;TD style="padding: 6px;"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Mar 2016 21:55:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-sequential-number-according-to-change-value/m-p/678375#M22530</guid>
      <dc:creator>AngelaKim2</dc:creator>
      <dc:date>2016-03-15T21:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: Adding sequential number according to change value of next field using ArcPy</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-sequential-number-according-to-change-value/m-p/678376#M22531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you post the original code you used for Field 2, we can go from there.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Mar 2016 21:58:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-sequential-number-according-to-change-value/m-p/678376#M22531</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-03-15T21:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Adding sequential number according to change value of next field using ArcPy</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-sequential-number-according-to-change-value/m-p/678377#M22532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;is that the limit of the examples? does the example define all the rules?&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;field 1, 4x, 2x, 4x with integer sequence &lt;/LI&gt;&lt;LI&gt;field 2 sequence from 1-19 based on sequence in the previous&lt;/LI&gt;&lt;LI&gt;field3&amp;nbsp; 1,2,3,4&amp;nbsp; 1,2&amp;nbsp;&amp;nbsp; 1,2,3,4 to match the sequencing in field 1&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so the next sequence would be&lt;/P&gt;&lt;P&gt;field 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 4 4 4 4 5 5 6 6 6 6&lt;/P&gt;&lt;P&gt;field 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 2 3 4 5 6 7 8 9 10&lt;/P&gt;&lt;P&gt;field 3&amp;nbsp;&amp;nbsp; 1 2 3 4 1 2 1 2 3 4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;just to check there are no hidden rules or exceptions&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Mar 2016 22:04:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-sequential-number-according-to-change-value/m-p/678377#M22532</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-03-15T22:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Adding sequential number according to change value of next field using ArcPy</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-sequential-number-according-to-change-value/m-p/678378#M22533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Darren,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the code I used for filling the Field 2.&amp;nbsp; (I have ArcGIS 10.3.1 by the way)&lt;/P&gt;&lt;P&gt;Source:&amp;nbsp; &lt;A href="http://support.esri.com/fr/knowledgebase/techarticles/detail/38517" title="http://support.esri.com/fr/knowledgebase/techarticles/detail/38517"&gt;38517 - Create sequential numbers in a field using Python in the Field Calculator&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Pre-Logic Script Code:&lt;/P&gt;&lt;P&gt;rec=0 &lt;/P&gt;&lt;P&gt;def autoIncrement(): &lt;/P&gt;&lt;P&gt; global rec &lt;/P&gt;&lt;P&gt; pStart = 1&amp;nbsp; &lt;/P&gt;&lt;P&gt; pInterval = 1 &lt;/P&gt;&lt;P&gt; if (rec == 0):&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; rec = pStart&amp;nbsp; &lt;/P&gt;&lt;P&gt; else:&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; rec += pInterval&amp;nbsp; &lt;/P&gt;&lt;P&gt; return rec&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression:&lt;/P&gt;&lt;P&gt;autoIncrement()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a vague idea of having double loop of entering sequential number to Field 3 as number changes in Field 1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rec=0&lt;/P&gt;&lt;P&gt;field1 = 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def autoIncrement(): &lt;/P&gt;&lt;P&gt; global rec &lt;/P&gt;&lt;P&gt; global field 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP1 field1 +=1 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOOP2 rec += 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END LOOP2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return rec&lt;/P&gt;&lt;P&gt;END LOOP1 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I appreciate your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Mar 2016 22:14:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-sequential-number-according-to-change-value/m-p/678378#M22533</guid>
      <dc:creator>AngelaKim2</dc:creator>
      <dc:date>2016-03-15T22:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Adding sequential number according to change value of next field using ArcPy</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/adding-sequential-number-according-to-change-value/m-p/678379#M22534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's kind of a simple/complex way to do it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;dict = {} # make a dictionary
def myFunc(myClass): # this is the function
&amp;nbsp; global dict # specify global
&amp;nbsp; dict[myClass] = dict.get(myClass, 0) + 1 # if the dictionary key for the value exists, add 1 to it. If not, make it 0.
&amp;nbsp; return dict[myClass] # return the value for that key&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;expression: myFunc(!Field_1!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit: I had a variable named 'class', which may be a reserved word.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:35:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/adding-sequential-number-according-to-change-value/m-p/678379#M22534</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-12T04:35:50Z</dc:date>
    </item>
  </channel>
</rss>

