AnsweredAssumed Answered

Field Calc, in Model Builder, using strings

Question asked by Christophersmith on Oct 30, 2019
Latest reply on Nov 1, 2019 by Christophersmith

Hello All, and thanks  for any help.


I am trying to take this block of Python and insert it into the Field Calculator.   What it is supposed to do is take a concatenated field (LF_Concat) and from within that field parse out the number of Greens (G), Yellows (Y), and Reds (R) and then apply a If/Than/elif to number of colors.


Right now I am at a loss on how to get it in.  I have this too show for it.  The parser while it shows VB is actually in Python  (I maybe slow, but I ain't that slow)

Progress Thwarted

I suspect that the delineatorList should be changed to the concatenated field (LF_concat)  but I am lost beyond that. 





delineatorList = [" ", ".", ","]

ColorClass =  ['GGGY','GGYY','GYYR']

for letters in ColorClass:
    #print letters, " G = ", letters.count('G')
    #print letters, " Y = ", letters.count('Y')
    #print letters, " R = ", letters.count('R')

    Count_G = letters.count('G')
    Count_Y = letters.count('Y')
    Count_R = letters.count('R')

    if Count_R > 0:
        print "Red"
    elif Count_R == 0 and Count_Y >= Count_G:
        print "Yellow"
    elif Count_R == 0 and Count_Y < Count_G:
        print "Green"