I have a log file as follows:
error 1020
warning 3000
this is an error and warning
I am attempting to filter out the lines that have the words error
or warning
in it.
In the first code, I had a bracket for the or
condition and in the second code I removed the bracket.
Can you please let me know why the removal of the bracket gives the right result?
>>> betterRDD = inputRDD.filter(lambda x: ("error" or "warning") in x)
>>> col4 = betterRDD.collect()
[Stage 3:> (0 + 2) / 2]
>>> print "The better result is %s" %col4
The better result is [u'error 1020', u'this is an error and warning']
>>> betterRDD = inputRDD.filter(lambda x: "error" or "warning" in x)
>>> col4 = betterRDD.collect()
[Stage 4:> (0 + 2) / 2]
>>> print "%s" %col4
[u'error 1020', u'warning 3000', u'this is an error and warning']
>>>