<?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: sequential id for each class which contain couple of hundred of points. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589980#M46257</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;just to be clear, my code was built with Service Pack 2 for ArcMap 10.1, so make sure you have installed Service Pack 2.&amp;nbsp; I don't know that there is any effect of the Service Pack that might relate to your problem, but it is best to eliminate that possibility.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code I provided before only ran as a Field Calculation.&amp;nbsp; It was not meant to be run as a Python script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To add the new subroutine you want that will fill in the Greatest Value field the code needs to be converted to a standalone script.&amp;nbsp; A Field Calculation cannot efficiently summarize data and update records with the summary data, but a script can.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So here is a script that should replace the Field Calculation that will assign with both the Sequence field values and the Greatest Value field values.&amp;nbsp; You should no longer need the field calculation if you use this script.&amp;nbsp; Make sure you customize the variable values for your data file name and path and for the field list so that it exactly matches your data set up:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import the arcpy module
import arcpy

pStart = 1 # adjust start value, if required 

pInterval = 1 # adjust interval value, if required

# Initialize the sequence number dictionary and the Route ID variables
seqDict = {}

CID = ""

# Assign data and field list variables.
# Customize these variable inputs for your specific data
myData = r"C:\MyPath\MyData.shp"

fields = ["CID", "SEQUENCE", "GREATEST"]

# Step 1 - Use an update cursor to assign Sequence numbers
rows = arcpy.da.UpdateCursor(myData, fields)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if row[0] is None:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CID = "Null"
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CID = row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; if CID in seqDict:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; seqDict[CID] = seqDict[CID] + pInterval
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; seqDict[CID] = pStart
&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = seqDict[CID]
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp; del row
del rows
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# Step 2 - Use an update cursor to assign the Greatest Value to all records
rows = arcpy.da.UpdateCursor(myData, fields)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if row[0] is None:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CID = "Null"
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CID = row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; row[2] = seqDict[CID]
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp; del row
del rows&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also want to make sure you understand that this code will only work if it runs on every record in your data and that it will overwrite any previously assigned sequence numbers if any records have changed.&amp;nbsp; To make the script continue any preexisting sequence numbering from any previous run of the tool the code would have to be changed to split Step 1 into two steps.&amp;nbsp; First a search cursor would have to populate the sequence dictionary with the maximum sequence number for all existing sequences and then an update cursor would have to run to actually update the new records that did not have sequences assigned to continue those sequences or begin new sequences for new routes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 01:20:39 GMT</pubDate>
    <dc:creator>RichardFairhurst</dc:creator>
    <dc:date>2021-12-12T01:20:39Z</dc:date>
    <item>
      <title>sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589967#M46244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hello python hero and legends.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i have more then 23 routes generated by using network analyst. later on, i have converted the route into point shapefile. new formed point shapefile have many hundred of points for each routes. i have created a&amp;nbsp; new column and i want to populate that column with sequential numbers for each point. a python script is available for such calculation but this scripts generates sequential number starting from 1st point to last one regardless the route class. i am looking for some advance calculation. i want sequential numbering for each route in new column. like&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;route type seq.no&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&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; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&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; so on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i need all this is a single python script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;looking forward your great contribution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Nadeem Fareed&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Sep 2013 05:30:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589967#M46244</guid>
      <dc:creator>nadeemfareed</dc:creator>
      <dc:date>2013-09-13T05:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589968#M46245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;hello python hero and legends.&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i have more then 23 routes generated by using network analyst. later on, i have converted the route into point shapefile. new formed point shapefile have many hundred of points for each routes. i have created a&amp;nbsp; new column and i want to populate that column with sequential numbers for each point. a python script is available for such calculation but this scripts generates sequential number starting from 1st point to last one regardless the route class. i am looking for some advance calculation. i want sequential numbering for each route in new column. like&lt;BR /&gt;route type seq.no&lt;BR /&gt;1&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;BR /&gt;1&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;BR /&gt;1&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;BR /&gt;1&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;BR /&gt;2&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;BR /&gt;2&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;BR /&gt;2&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&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; &lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&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; so on.&lt;BR /&gt;i need all this is a single python script.&lt;BR /&gt;looking forward your great contribution.&lt;BR /&gt;&lt;BR /&gt;Nadeem Fareed&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;there are things known and there are things unknown inbetween are doors&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Sep 2013 08:34:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589968#M46245</guid>
      <dc:creator>nadeemfareed</dc:creator>
      <dc:date>2013-09-13T08:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589969#M46246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;hello python hero and legends.&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i have more then 23 routes generated by using network analyst. later on, i have converted the route into point shapefile. new formed point shapefile have many hundred of points for each routes. i have created a&amp;nbsp; new column and i want to populate that column with sequential numbers for each point. a python script is available for such calculation but this scripts generates sequential number starting from 1st point to last one regardless the route class. i am looking for some advance calculation. i want sequential numbering for each route in new column. like&lt;BR /&gt;route type seq.no&lt;BR /&gt;1&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;BR /&gt;1&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;BR /&gt;1&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;BR /&gt;1&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;BR /&gt;2&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;BR /&gt;2&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;BR /&gt;2&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; point&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&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; &lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&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; so on.&lt;BR /&gt;i need all this is a single python script.&lt;BR /&gt;looking forward your great contribution.&lt;BR /&gt;&lt;BR /&gt;Nadeem Fareed&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have adapted the standard Python AutoIncrement Field Calculation to use a dictionary to keep track of the Route ID count, which I believe will do what you want:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Parser:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Show Codeblock:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Checked&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pre-Logic Script Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;recDict = {}
def autoIncrement(RID):
&amp;nbsp; global recDict
&amp;nbsp; pStart = 1 # adjust start value, if required 
&amp;nbsp; pInterval = 1 # adjust interval value, if required
&amp;nbsp; if RID in recDict:
&amp;nbsp;&amp;nbsp;&amp;nbsp; recDict[RID] = recDict[RID] + pInterval 
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; recDict[RID] = pStart 
&amp;nbsp; return recDict[RID]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;autoIncrement(!RID!) # Put your Route ID field name in the parentheses.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The records will sequence in the order that they are encountered in the point fc, which will be the order of the points along the route if that is the order they are stored in the point fc by your route conversion to point method.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:20:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589969#M46246</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-12T01:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589970#M46247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I had the chance to test my code and it worked.&amp;nbsp; So this is the calculation you need and all you should need to do is match your Route ID case field.&amp;nbsp; I did not test a Null value in the RID field, so it is possible that if Null values can be in your Route ID field that the code would need to be modified slightly.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Sep 2013 18:24:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589970#M46247</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2013-09-13T18:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589971#M46248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;dear sir&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; see the attachment for detail. its not working.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Sep 2013 03:59:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589971#M46248</guid>
      <dc:creator>nadeemfareed</dc:creator>
      <dc:date>2013-09-16T03:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589972#M46249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;dear sir&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; see the attachment for detail. its not working.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Screen shot the actual field calculator screen.&amp;nbsp; It does work, so something is wrong in the way it was transferred, but I can't tell from the result screen, since I don't use that to evaluate failures.&amp;nbsp; Maybe at work I can recheck it.&amp;nbsp; But the calculation works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The expression should not contain the word "def " in front of the AutoIncrement(!CID!).&amp;nbsp; "def " should only occur in the codeblock.&amp;nbsp; Did you type that word in the expression, or did the results tab insert that word in the expression?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit:&amp;nbsp; After running the calculation and looking at the results tab inputs, I have confirmed that you should not have the word "def " in the expression portion of the calculation, only in the codeblock portion.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Sep 2013 12:11:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589972#M46249</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2013-09-16T12:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589973#M46250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hello everyone&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the script given in response to my post by rfairhur24&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;is not working well i tried it many ways i request rfairhur24, please try it and then send me back. i try hard to get job done with this script but its not working. i also request the other user or expert to please do me favor and just post something different and new for this task. i also request rfairhur24 please provide me stand alone python script that can work like a tool, any thing that could work batter. there is another option that i have&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;each route have single unique ID named CID.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for every route CID is different like for route no 1. points CID is 1, for route no.2 CID is 2 same is true for 23 routes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i am looking for a scripts that generate the sequential ID for each CID.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;best regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Nadeem Fareed&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 05:13:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589973#M46250</guid>
      <dc:creator>nadeemfareed</dc:creator>
      <dc:date>2013-09-20T05:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589974#M46251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;hello everyone&lt;BR /&gt;the script given in response to my post by rfairhur24&lt;BR /&gt;is not working well i tried it many ways i request rfairhur24, please try it and then send me back. i try hard to get job done with this script but its not working. i also request the other user or expert to please do me favor and just post something different and new for this task. i also request rfairhur24 please provide me stand alone python script that can work like a tool, any thing that could work batter. there is another option that i have&lt;BR /&gt;each route have single unique ID named CID.&lt;BR /&gt;for every route CID is different like for route no 1. points CID is 1, for route no.2 CID is 2 same is true for 23 routes.&lt;BR /&gt;i am looking for a scripts that generate the sequential ID for each CID.&lt;BR /&gt;&lt;BR /&gt;best regards&lt;BR /&gt;Nadeem Fareed&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Do me a favor and screen shot your actual calculation input as I requested.&amp;nbsp; The only test you showed me a screen shot for had a definite error in the way you transferred my code to the Field Calculator.&amp;nbsp; Since the code I provided works when I input it into the field calculator (tested on over 10,000 unique Route IDs each with between 1 and 300 sequenced events, so more than an adequate test to say it should work for your small data set), I want to eliminate user failure as the reason for your failed attempts to make my code work and a screen shot would be the best way to do that.&amp;nbsp; I would screen shot my calculation for you, but at the moment I cannot access my system remotely to do that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you sure there are absolutely no Null values in the CID field?&amp;nbsp; If there were the calculation would fail.&amp;nbsp; So on the off chance that is the problem I have added code below to deal with that situation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any standalone script I would write would be based on the same code, so before I go to the trouble of trying to come up with any other script code try setting the calculation up exactly as shown below and screen shot your Field Calculator set up and results so I can verify you correctly transferred the calculation to the Field Calculator first.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It should be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Parser: Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Show Codeblock:&amp;nbsp; Checked&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pre-Logic Script Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;recDict = {}
def autoIncrement(CID):
&amp;nbsp; global recDict
&amp;nbsp; pStart = 1 # adjust start value, if required 
&amp;nbsp; pInterval = 1 # adjust interval value, if required
&amp;nbsp; if not CID:
&amp;nbsp;&amp;nbsp;&amp;nbsp; CID = "Null"
&amp;nbsp; if CID in recDict:
&amp;nbsp;&amp;nbsp;&amp;nbsp; recDict[CID] = recDict[CID] + pInterval 
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; recDict[CID] = pStart 
&amp;nbsp; return recDict[CID]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&amp;nbsp; autoIncrement(!CID!)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:20:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589974#M46251</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-12T01:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589975#M46252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There is a geoprocessing way to do this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.&amp;nbsp; If your data is not already sorted by CID values, first run the Sort tool with the sort fields being the CID field and the ObjectID field.&amp;nbsp; I will call the output "Sorted"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2.&amp;nbsp; On the sorted output add a long field called something like Sequence.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3.&amp;nbsp; Calculate the Sequence field to be equal to the ObjectID.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;4.&amp;nbsp; Do a Summary Statistics of the Sorted feature class using the CID field as the case field and the Min of the Sequence field as the summary.&amp;nbsp; I will call the output "Summary".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;5.&amp;nbsp; Make the sorted output a Feature Layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;6.&amp;nbsp; Join the sorted feature layer as the target and the summary as the join table on the common CID fields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;7.&amp;nbsp; Calculate the Sequence field to be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorted.Sequence - Summary.Min_Sequence + 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;8.&amp;nbsp; Remove the Join.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Sequence field will now contain a sequential ID that restarts the numbering at 1 for each CID value.&amp;nbsp; Null values in the CID field would potentially mess this up, but I think it would handle that correctly.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 10:56:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589975#M46252</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2013-09-20T10:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589976#M46253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I just added the calculation to a model and it performed perfectly for 30,000+ routes each with between 1 to 182 sequenced events.&amp;nbsp; Here are screen shots of my calculation (part 1 and 2 to scroll the full code in the code block).&amp;nbsp; So if you duplicate that set up exactly it should work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 20:51:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589976#M46253</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2013-09-20T20:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589977#M46254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;yes it working now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; thanks buddy rfairhur24&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;its really very great job i really appriciate.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;you did well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;one more task for you if you feel easy. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;in next column i want to find the great value of sequential number generated through this script. for each route. like route 1 as great value or number of counts equal to 305. the next colum should populate with this number for each point of route 1. similarly for each rroute.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SEQ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GREATEST VALUE&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1&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; 1&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1&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; 2&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1&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; 3&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1&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; 4&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;this is the final task for me. after this my application will be fully functional. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;once again thanks for your golden time with me&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Sep 2013 09:45:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589977#M46254</guid>
      <dc:creator>nadeemfareed</dc:creator>
      <dc:date>2013-09-22T09:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589978#M46255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;dear rfairhur24.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; i have some issues with script you have provided to me, now, its ok with arcgis 10 version but its giving error in 10.1 version. arcgis 10 have python version 2.6.5 while arcgis 10.1 have python version 2.7.2. so script in python 2.7.2 version show some error in script like indent error like somethin. please could you fix the compatibility errors please. i try my hard to do this but i am not hero of python like you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for response&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 05:17:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589978#M46255</guid>
      <dc:creator>nadeemfareed</dc:creator>
      <dc:date>2013-09-24T05:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589979#M46256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;dear rfairhur24.&lt;BR /&gt;&lt;BR /&gt; i have some issues with script you have provided to me, now, its ok with arcgis 10 version but its giving error in 10.1 version. arcgis 10 have python version 2.6.5 while arcgis 10.1 have python version 2.7.2. so script in python 2.7.2 version show some error in script like indent error like somethin. please could you fix the compatibility errors please. i try my hard to do this but i am not hero of python like you.&lt;BR /&gt;&lt;BR /&gt;thanks for response&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;No error here and I originally wrote it using ArcGIS 10.1 and it is using Python 2.7.2 on my system, so that is not the problem.&amp;nbsp; The Python version makes no difference.&amp;nbsp; None of the code I wrote would break between those versions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again, you need to screenshot what you are doing for me to troubleshoot this, since there are no indent errors in the code I am using.&amp;nbsp; Even a single extra or missing space character will break the code, so I can only spot it from a screenshot.&amp;nbsp; My code could not cause an indent error as I wrote it and the ArcGIS version or Python version could not cause that kind of error.&amp;nbsp; So screenshot please.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 05:38:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589979#M46256</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2013-09-24T05:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589980#M46257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;just to be clear, my code was built with Service Pack 2 for ArcMap 10.1, so make sure you have installed Service Pack 2.&amp;nbsp; I don't know that there is any effect of the Service Pack that might relate to your problem, but it is best to eliminate that possibility.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code I provided before only ran as a Field Calculation.&amp;nbsp; It was not meant to be run as a Python script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To add the new subroutine you want that will fill in the Greatest Value field the code needs to be converted to a standalone script.&amp;nbsp; A Field Calculation cannot efficiently summarize data and update records with the summary data, but a script can.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So here is a script that should replace the Field Calculation that will assign with both the Sequence field values and the Greatest Value field values.&amp;nbsp; You should no longer need the field calculation if you use this script.&amp;nbsp; Make sure you customize the variable values for your data file name and path and for the field list so that it exactly matches your data set up:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import the arcpy module
import arcpy

pStart = 1 # adjust start value, if required 

pInterval = 1 # adjust interval value, if required

# Initialize the sequence number dictionary and the Route ID variables
seqDict = {}

CID = ""

# Assign data and field list variables.
# Customize these variable inputs for your specific data
myData = r"C:\MyPath\MyData.shp"

fields = ["CID", "SEQUENCE", "GREATEST"]

# Step 1 - Use an update cursor to assign Sequence numbers
rows = arcpy.da.UpdateCursor(myData, fields)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if row[0] is None:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CID = "Null"
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CID = row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; if CID in seqDict:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; seqDict[CID] = seqDict[CID] + pInterval
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; seqDict[CID] = pStart
&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = seqDict[CID]
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp; del row
del rows
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# Step 2 - Use an update cursor to assign the Greatest Value to all records
rows = arcpy.da.UpdateCursor(myData, fields)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if row[0] is None:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CID = "Null"
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CID = row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; row[2] = seqDict[CID]
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp; del row
del rows&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also want to make sure you understand that this code will only work if it runs on every record in your data and that it will overwrite any previously assigned sequence numbers if any records have changed.&amp;nbsp; To make the script continue any preexisting sequence numbering from any previous run of the tool the code would have to be changed to split Step 1 into two steps.&amp;nbsp; First a search cursor would have to populate the sequence dictionary with the maximum sequence number for all existing sequences and then an update cursor would have to run to actually update the new records that did not have sequences assigned to continue those sequences or begin new sequences for new routes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:20:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589980#M46257</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2021-12-12T01:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589981#M46258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;just to be clear, my code was built with Service Pack 2 for ArcMap 10.1, so make sure you have installed Service Pack 2.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Service pack 2? Did I miss a memo?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 14:04:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589981#M46258</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-09-24T14:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: sequential id for each class which contain couple of hundred of points.</title>
      <link>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589982#M46259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Service pack 2? Did I miss a memo?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Nope, just wishful thinking on my part.&amp;nbsp; I meant Service Pack 1.&amp;nbsp; Sorry.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Sep 2013 14:07:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-id-for-each-class-which-contain-couple/m-p/589982#M46259</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2013-09-24T14:07:50Z</dc:date>
    </item>
  </channel>
</rss>

