I have a table (inside a File Geodatabase) that looks like this:

enter image description here

I need the values of Owner attribute to be automatically filled with the previous non-Null value. As Such:

enter image description here

Is there a Python script, usable in Field Calculator, that can achieve this?

2 Answers 2


You can do this directly within the CalculateField tool; use the following code block:

prevval = None

def calcowner(ownerval):
    global prevval
    val = prevval if ownerval is None else ownerval
    prevval = val
    return val

And the expression:


Note that this probably won't work in ArcGIS 10.0 due to a bug that was fixed in 10.1, but 10.1+ should be good:

NIM059424 - Null values in the feature class do not get replaced when using Python in the Field Calculator.


This can be done with a custom python parser function like:

Here we evaluate if value is NULL or not, if not write value to text file, if NULL pull value from text file:

def update(val):
  if val:
    f = open('C:/Temp/temp.txt','w')
    return val
     f = open('C:/Temp/temp.txt','r')
     for v in f:
         return v

And add the function call in the text box below the pre logic one:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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