samirz10

looping through grouped records

Discussion created by samirz10 on Jul 6, 2011
Latest reply on Jul 9, 2011 by samirz10
Hello All,

I am new to python scripting and need to write a code to basically loop through selected records of a feature class.
Here's a sample of how attribute table looks like. I have also attached a pgdb.
OBID ID FromLeft ToLeft FromRightToRight Flag
1 1 0 9 2 10
2 1 8 19 12 24
3 22 3 23 2 12
4 3 0 0 4 16
5 1 21 29 26 30
6 3 0 11 18 22
7 1 27 31 32 42
8 3 13 19 22 28


Here's what I am trying to do.

1. Grab all the records with same id (say ID=1)
2. sort "FromLeft" in ascending order
3. Skip the first record
3. compare "FromLeft" value (ie. 2nd record) with "ToLeft" value of previous record (ie. 1st record)
4. if "FromLeft" value <= "ToLeft" value of previous record, export both records to a new table or flag it by populating a new field
5. Sort "FromRight" and repeat the same process
6. Once this is done for all the records with ID=1, move on to next set of records with same id, (say ID=3)


Any help will be greatly appreciated.

Thank you.

Attachments

Outcomes