3

I would like to remove the NULL/empty values from a table that is stored in a Geodatabase. Last time I tried doing so it worked fine, today I have some issues with the codes (Double Field). I have used the following python sequence;

Pre-logic:

def RemoveNULL(x):
  if x is None:
    return '0'
  elif x == ' ':
    return '0'
  else: return x

Second Field:

    RemoveNULL(!Field_name!)

According to my opinion the code is correct but the Geoprocessing window illustrates a failure each time I calculate just after 1-3 seconds.

2
  • 1
    What is the error message that you get?
    – Martin
    Aug 23, 2016 at 9:20
  • Hello Martin, the error message is a generic one: 'ERROR 999999: Error executing function'. Below, I have two more; 'Expected 'Then'' and ' Failed to execute (CalculateField)'. Thanks.
    – SebastianH
    Aug 23, 2016 at 9:23

1 Answer 1

4

Im sure this is Python and not VB script. By putting the 0 in speech marks, you are trying to say that 0 is a string, when its not. As added by Martin, please select the Python Parser instead of the VB Script Parser. Try and use the following code:

def RemoveNULL(x):
  if x is None:
    return 0
  elif x == ' ':
    return 0
  else: 
    return x
2
  • 1
    Yeah, and also make sure to use the Python parser!
    – Martin
    Aug 23, 2016 at 9:29
  • Using the Python parser and the amended code helped. Thank you both very much!
    – SebastianH
    Aug 23, 2016 at 9:31

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.