i want to filter my dataframe from an external file. this is how my dataframe look like:
val Insert=Append_Ot.filter(col("Name2").equalTo("brazil") || col("Name2").equalTo("france") || col("Name2").equalTo("algeria")|| col("Name2").equalTo("tunisia") || col("Name2").equalTo("egypte") )
The number of countries that i want to filter them is changeable, so created an external this file:
1 brazil
2 france
3 algeria
4 tunisia
5 egypte
i want to create UDF to filter my dataframe from this file.
Thank you
You need to create a
Seq
from the file with which you want to filter. Something that looks like this:You can use
textFile
method. Suppose your file contains:You can use:
which will give you:
And then, use the
isin
function on your columnName2