2

I'm using the Python FuelSDK, and I want to pull all rows of a DE where a specific field is not null.

I've tried both of these for the search_filter:

{'Property': 'FieldName', 'SimpleOperator': 'notEquals', 'Value': None}
{'Property': 'FieldName', 'SimpleOperator': 'notEquals', 'Value': ''}

When I use None I get this error:

Error: Invalid argument for the notEquals operator. Filter array cannot be null.

When I use '' I get:

Error: Invalid argument for the notEquals operator. Filter[0] cannot be null or empty.

Is there a way to do this?

2
  • I'm not familiar with the Python FuelSDK, but have you tried the name/value pair 'Value': null ? Commented Sep 20, 2016 at 11:02
  • None is the python equivalent of Null. 'Value': Null throws an error. Commented Sep 20, 2016 at 13:55

2 Answers 2

3
+50

I am unfamiliar with the Python Fuel SDK, so my first suggestion could be completely dumb due to my ignorance.

Can you use the simpleoperator "isNotNull" equivalent in python (if it exists)?

This next answer is not exactly the most elegant solution, but you could try:

1 Pull the rows (without filters)

2 Take a rowcount of the data and start a for loop

3 For loop should be something like: (using ampscript as example)

FOR @i = 1 TO @rowcount  DO 
   SET @row = Row(@yourdata,@i)        
   SET @length = length(field(@row,'Fieldname'))

   IF @length > 0 THEN
       ADD to a new object/array or DE, whichever you prefer
   ENDIF

NEXT @i

Another option to use instead of Length() is to use the IsNull() or EMPTY() function instead.

4 Use the new DE or object/array for your need.

This will definitely add time to your scripts, so on a large file it will not work - but as I do not see a simple alternative via the filter function I thought I should share.

A final option, very much duct tape and gum, is to build a filter activity that uses the argument "Fieldname is empty" and call that activity as your filter. The issue is that it will only work on a single Data Extension and cannot be used universally or on non-data extensions.

2
  • Yeah, I'm pulling all rows now and doing the filtering in python, but scale is becoming an issue. There's at least a dozen DEs I need to pull nightly, and being able to have a not null filter would speed it up immensely. The good news is, 'isNotNull' seems to work. Thanks for linking that page with the other SimpleOperator functions. That's super useful, and I hadn't seen it before. Commented Sep 22, 2016 at 13:59
  • Glad to hear I could help even a little bit. Yeah, there are a lot of cool reference pages available, but unfortunately SFMC is not very good at making these pages searchable or easy to find/naviage to for some reason. Commented Sep 22, 2016 at 15:39
1

Just FYI if anyone ends up here: was being bothered by isNull / isNotNull filters in a Script Activity for a while and just found out that you can make it work this way:

var filter = {
  Property: 'Status',
  SimpleOperator: 'isNull',
  Value: ''
}

The key is leaving the Value: '' in the filter object as there'll be an error otherwise.

1
  • Thank you - I searched the entire internet for this answer! Commented Mar 1 at 13:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .