Basically, I have a large polygon data set that has soil data for an area and I want to assign numeric values to the data based on soil texture text values (e.g. SIL=4, CLY=7, ...). However, the soil texture is divided into three different columns: 1) TEXTURE1; 2) TEXTURE2; and, 3) TEXTURE3. Usually TEXTURE1 gives me the data I need to assign the numeric value in a new field, but in some cases the value for TEXTURE1 is listed as N/A, and I need to use the text from TEXTURE2 to assign the number. Is it possible to write a script where if the text from the TEXTURE1 field is NOT N/A return TEXTURE1, else return TEXTURE2? The new field would be a text field.
Perhaps something like this?
def GetTexture(Text1,Text2): if Text1 is None: return Text2 else: return Text1
With expression NEWTEXTURE = GetTexture(!TEXTURE1!, !TEXTURE2!)
Fisrt I would compile lookup tables for TEXTURE1, TEXTURE2 and TEXTURE3 using Summary Statistics (to find all the unique values), statistics doesn't matter all you want is each TEXTURE field as a 'case' field. Add Field to add the value you want to apply to each statistics table to make it into a lookup table, delete the statistics fields if you wish with Delete Field (you can do more than one field at a time).
Now the tedious part, edit the table, delete instances of
Null from the table, and put the value you want to apply next to the code in the tables (all 3 could be different).
Start by joining the Lookup table for TEXTURE1, selecting matching records only and apply the matching value using Field Calculator (joined fields should be named with the table name then field name), then remove the join and join the TEXTURE2 lookup table to the TEXTURE2 field (also matching records only). Now, select in the table the ones that haven't been calculated (TargetField is NULL) and calculate the values over the join on selected records only. Remove the join and do the same for TEXTURE3.
Now all the TargetField values are populated where there is a value in TEXTURE1, TEXTURE2 or TEXTURE3, with an order of preference.
There are more steps involved but once you've done this procedure once you'll get the idea of how it works - also keep the lookup tables in case you want to do this again.