2016-11-15 57 views
0

我试图用猪过滤器方法过滤掉数据。但是我不想过滤掉空的字符串。以下过滤器将过滤出我想要的内容,但它也会过滤掉(动作匹配“'),我不会要求它。任何方式在这个?为什么猪过滤出空串,尽管没有问它?

filtered = filter distinctVals by not ((action matches 'Identified') or (action matches 'Initiated') or (action matches 'Completed')); 
+0

我希望它只是排除那些3动作。但是,如果操作是空字符串,它也是排除的。 – Pxl

+0

如果答案很有用,您可以点击向上箭头。如果它解决了你的问题,你可以点击复选标记图标。 –

回答

0

过滤器不工作就像“过滤”。他们通过“过滤”工作。

你可以从example看到。过滤器的结果

filter_data = FILTER student_details BY city == 'Chennai'; 

是只有有项目奈:

(6,Archana,Mishra,23,9848022335,Chennai) 
(8,Bharathi,Nambiayar,24,9848022333,Chennai) 

你的代码,所以应排除not

filtered = filter distinctVals by ((action matches 'Identified') or (action matches 'Initiated') or (action matches 'Completed')); 
+0

好吧,所以我试图“过滤”,但我没有办法过滤空字符串。通过((动作匹配'错误')或(动作匹配'失败')或(动作匹配''))过滤distinctVals;不包含空字符串的结果 – Pxl

+0

@Pxl:然后使用'=='而不是'matches'。 'matches'将是一个正则表达式。 –