<?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 Python Sequential Number Gen starting value in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-sequential-number-gen-starting-value/m-p/654838#M50991</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Looking for a way to adapt this Python sequential number generator to use the LAST value +1 in a given field for pStart:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rec=0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def autoIncrement():&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; global rec&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pStart = 1 #adjust start value, if req'd &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pInterval = 1 #adjust interval value, if req'd&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if (rec == 0): &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; rec = pStart &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; else: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; rec = rec + pInterval &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return rec&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;autoIncrement()&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 Apr 2011 18:01:34 GMT</pubDate>
    <dc:creator>GabeMarcello</dc:creator>
    <dc:date>2011-04-11T18:01:34Z</dc:date>
    <item>
      <title>Python Sequential Number Gen starting value</title>
      <link>https://community.esri.com/t5/python-questions/python-sequential-number-gen-starting-value/m-p/654838#M50991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Looking for a way to adapt this Python sequential number generator to use the LAST value +1 in a given field for pStart:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rec=0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def autoIncrement():&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; global rec&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pStart = 1 #adjust start value, if req'd &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pInterval = 1 #adjust interval value, if req'd&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if (rec == 0): &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; rec = pStart &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; else: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; rec = rec + pInterval &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return rec&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;autoIncrement()&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Apr 2011 18:01:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-sequential-number-gen-starting-value/m-p/654838#M50991</guid>
      <dc:creator>GabeMarcello</dc:creator>
      <dc:date>2011-04-11T18:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Python Sequential Number Gen starting value</title>
      <link>https://community.esri.com/t5/python-questions/python-sequential-number-gen-starting-value/m-p/654839#M50992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There's probably a one-liner function out there that tells you the last number in a list of numbers, but this works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

input = "H:/GIS_Data/TEMP_GDB.gdb/feattoline" # your feature class
field = "OBJECTID A" # the name of the field, sorted ascending

rows = arcpy.SearchCursor(input,"","","",field)

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; number = row.OBJECTID
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;This code simply sorts the values in the field "OBJECTID," assigns and overwrites that value to the variable "number" for each increasing value. Finally, you're left with the largest value of "OBJECTID." Then, make pStart = number.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:44:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-sequential-number-gen-starting-value/m-p/654839#M50992</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-12T03:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: Python Sequential Number Gen starting value</title>
      <link>https://community.esri.com/t5/python-questions/python-sequential-number-gen-starting-value/m-p/654840#M50993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;There's probably a one-liner function out there that tells you the last number in a list of numbers, but this works:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

input = "H:/GIS_Data/TEMP_GDB.gdb/feattoline" # your feature class
field = "OBJECTID A" # the name of the field, sorted ascending

rows = arcpy.SearchCursor(input,"","","",field)

for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; number = row.OBJECTID
&lt;/PRE&gt;&lt;BR /&gt;This code simply sorts the values in the field "OBJECTID," assigns and overwrites that value to the variable "number" for each increasing value. Finally, you're left with the largest value of "OBJECTID." Then, make pStart = number.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This worked exactly how I wanted it to. Thank you. You truly are the wind beneath my wings.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:44:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-sequential-number-gen-starting-value/m-p/654840#M50993</guid>
      <dc:creator>GabeMarcello</dc:creator>
      <dc:date>2021-12-12T03:44:37Z</dc:date>
    </item>
  </channel>
</rss>

