1

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?

  • I'm not familiar with the Python FuelSDK, but have you tried the name/value pair 'Value': null ? – Eliot Harper Sep 20 '16 at 11:02
  • None is the python equivalent of Null. 'Value': Null throws an error. – Joe LeKostaj Sep 20 '16 at 13:55
2
+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.

|improve this answer|||||
  • 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. – Joe LeKostaj Sep 22 '16 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. – Gortonington Sep 22 '16 at 15:39

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.