2016-11-15 54 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'將是一個正則表達式。 –