Jump to content
Sign in to follow this  
samirz10

looping through grouped records

Recommended Posts

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.