In my feature table I have a column labeled 'Sequence' which I would like to add sequential numbering to which resets with each new day.
example:
Date Sequence
8/3/2020 | 1
8/3/2020 | 2
8/3/2020 | 3
8/3/2020 | 4
8/4/2020 | 1
8/4/2020 | 2
Are you looking for an automated solution to correct a few months of sequence data? I've done that sort of things with an update cursor:
fc = r'C:\some\path\to\your\data' startValue = 1 fields = ['YourFieldName'] where = "A a sql select statement for a particular date' arcpy.MakeFeatureLayer_management(fc,'fcLayer') arcpy.SelectLayerByAttribute_management('fcLayer', 'NEW_SELECTION', where) with arcpy.da.UpdateCursor('fcLayer',fields)as cursor: for row in cursor: row[0] = startValue cursor.updateRow(row) startValue += 1 <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
If you have a list of dates, you could loop through it and create the where statement on the fly. I think the update cursor will update in order of object id for the selected set, but don't quote me on that.
***Untested for this particular application...
What product are you using? "Traditional Desktop (10.x)" or ArcGIS Pro?
If the latter, you could write a script that deletes and then re-creates a database sequence, and run it every night at 00:00:01 hours as a scheduled task.
Create Database Sequence (Data Management)—ArcGIS Pro | Documentation
Delete Database Sequence (Data Management)—ArcGIS Pro | Documentation
ListDatabaseSequences—ArcGIS Pro | Documentation (only available for file geodatabases: vote here to have it ported to enterprise geodatabases... https://community.esri.com/ideas/18798 )
This is in ArcPro. I currently have script that runs this each night for the current day but recently it had a hiccup so I'm having to go back and correct a few months of sequence data.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.