AnsweredAssumed Answered

Iterate through rows and write new fields based on a criteria matched with reference table

Question asked by magar1982 on Jul 15, 2015
Latest reply on Jul 15, 2015 by xander_bakker


I am trying to iterate through rows in a attribute table( named here :target_table) and look for certain search criteria based on  a reference_table.csv. Search criteria is a set of numbers (see below), if criteria is met then I would like to add new fields in target_table and write with values based on the reference_table.



  ScreenHunter_44 Jul. 15 10.19.jpg

Columns: sec1,sec2,sec3 and sec4  are used as a criteria to search in target_table rows (see below). Example, in the first row: 5,6,31,32(order is not an issue), if this combination of numbers matches while scanning through first 4 rows in the target_table then "Pick" and "cornderID" column will be added into target_table with their values 31 and 200100 respectively.



ScreenHunter_47 Jul. 15 13.12.jpg

This is a shape attribute table where script will scan trough column "label" then look for the first 4 rows( moving downward) and search for criteria(as mention above) and add new fields "Pick" and "cornerID" with their values . Example, the first 4 rows combination under field "label" is 1,6,36,31,  so based on the search criteria from the reference_table, it should write Pick is 36 and cornerId is 700100. Below is what would final attribute table would look like;



ScreenHunter_50 Jul. 15 13.26.jpg


Any suggestion with arcpy scripting and tools will be greatly appreciated !


Thanks !