1

I am looking for a hand writing a python script in the Field calc, as it looks like I am stuck. Here is a screen shot of my table:

enter image description here

What I need to do is populate the "status" field by parsing through each actual (act) field in order. If the recon_act field is populated, move to the Socons_act field, if that is populated, move to the stake_act field and so on. If the act field is not populated, that is the status of the project. For instance, the 15th project does not have an act date in Recon_act, so the status will be "RECON". A dozen or so down from that a project has a date in the recon_act field but not the SOcons_act field, so that status will be "SOcons".

The 4th project down has dates in the Recon_act field, Socons_act field, stake_act field but not the plat_act field so that status will be "PLAT".

In my brain, the python statement needs to look something like this:

If [recon_act] = ‘ ‘ then Status = “RECON”

Elseif [SOcons_pro] = ‘ ‘ then Status = “Socons”

Elseif [stake_act] = ‘ ‘ then Status = “STAKE”

Elseif [plat_act] = ‘ ‘ then Status = “PLAT”

Elseif ………

0

What you need to use is the field calculator.

The expression :

cal (!Recon_act!, !SOcons_act!, !Stake_act!, !Plat_act!, !permit_act!, !PerRec_act!, !status!)

The codeblock should say:

def cal(rec_a, soc_a, stk_a, plat_a, perm_a, per_a, status):
    if (rec_a is not None) or (rec_a == " "):
       return "Recon"
    elif (soc_a is not None) or (soc_a == " "):
        return "Socons"
    elif (stk_a is not None) or (stk_a == " "):
        return "Stake"
    elif (plat_a is not None) or (plat_a == " "):
        return "Plat"
    elif (perm_a is not None) or (perm_a == " "):
        return "Perm"
    elif (per_a is not None) or (per_a == " "):
        return "Perec"
0
def function(recon_act, socons_pro, stake_act, plat_act):
    if recon_act is not None:
        return "RECON"
    elif socons_pro is not None:
        return "Socons"
    elif stake_act is not None:
        return "STAKE"
    elif plat_actis not None:
        return "PLAT"

Or if your field values are not NULL, you should replace is not None with == ""

And then:

function(!recon_act!, !socons_pro!, !stake_act!, !plat_act!)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.