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.

Midavalo
30k11 gold badges53 silver badges108 bronze badges
asked Aug 23, 2016 at 9:17
2
  • 1
    What is the error message that you get? Commented 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. Commented Aug 23, 2016 at 9:23

1 Answer 1

5

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
answered Aug 23, 2016 at 9:27
2
  • 1
    Yeah, and also make sure to use the Python parser! Commented Aug 23, 2016 at 9:29
  • Using the Python parser and the amended code helped. Thank you both very much! Commented Aug 23, 2016 at 9:31

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.