Dynamic segmentation + Arcpy

4325
4
05-05-2015 02:29 PM
ChukwuemekaEzeiruaku
New Contributor II
Item IDBegin EndTestDateConstruction
10000119982000
10010520012000
10021419982000
10034519982000
10043520052000

Requirments include:-

- I would like to segment the dataset to eliminate records with older TestDate to Construction date

- Output table should be non overlapping (begin/end)

Should look like below:-

   

Item IDBegin EndTestDateConstruction
10010320012000
10043520052000
10025719991998

Thanks

0 Kudos
4 Replies
JaiSiva1
New Contributor III

Hi Chukwuemeka,

  If these are the attributes of a feature class , the following code might help :

import arcpy
fc = "c:/data/base.gdb/construct"
fields = ('TestDate', 'Construction')
with arcpy.da.UpdateCursor(fc, fields) as cursor:
    for row in cursor:
       if row[0] < row[1]:
          cursor.deleteRow ()

Hope you would find this useful.

ChukwuemekaEzeiruaku
New Contributor II

Thanks so much for the code, i was able to get that part done.

Is there a way either with python scripts or other solution to segment the following table to get the result below?

Input table (not a feature class) 

Item IDBegin EndTestDate
1000011998
1001052001
1002171999
1003451998
1004352005

Each segmented section (from-to) should have all the item numbers written to a field that is within a certain range. From the input table, the final table should look like the one below:

Output table

Begin EndTestDateItem IDItem ID
01199810001001
13200110011001; 1002
34199910021001; 1002; 1004
45199810031001; 1002; 1003; 1004
57200510041002

Again Thanks.

0 Kudos
JaiSiva1
New Contributor III

Hi Chukwuemeka,

From the comparing the input table and output table , it is hard for me to find a condition using which the      output table is generated.

If you can explain the condition & logic involved in detail , it will be helpful.

0 Kudos
BlakeTerhune
MVP Regular Contributor

This appears to be a duplicate post. The other thread has more responses.

Dynamic segmentation with respect to a control factor