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.
-
1What is the error message that you get?Martin– Martin2016年08月23日 09:20:39 +00:00Commented 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– SebastianH2016年08月23日 09:23:37 +00:00Commented Aug 23, 2016 at 9:23
1 Answer 1
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
-
1Yeah, and also make sure to use the Python parser!Martin– Martin2016年08月23日 09:29:42 +00:00Commented Aug 23, 2016 at 9:29
-
Using the Python parser and the amended code helped. Thank you both very much!SebastianH– SebastianH2016年08月23日 09:31:30 +00:00Commented Aug 23, 2016 at 9:31
Explore related questions
See similar questions with these tags.