I am trying to filter this txt file
TotalCost|BirthDate|Gender|TotalChildren|ProductCategoryName
1000||Male|2|Technology
2000|1957-03-06||3|Beauty
3000|1959-03-06|Male||Car
4000|1953-03-06|Male|2|
5000|1957-03-06|Female|3|Beauty
6000|1959-03-06|Male|4|Car
I simply want to filter every raw and drop it if a column has a null element.
In my sample dataset there are three of them which are null.
However I am getting and empty datascheme when i run the code. Do I miss something?
This is my code in scala
import org.apache.spark.sql.SparkSession
object DataFrameFromCSVFile {
def main(args:Array[String]):Unit= {
val spark: SparkSession = SparkSession.builder()
.master("local[*]")
.appName("SparkByExample")
.getOrCreate()
val filePath="src/main/resources/demodata.txt"
val df = spark.read.options(Map("inferSchema"->"true","delimiter"->"|","header"->"true")).csv(filePath)
df.where(!$"Gender".isNull && !$"TotalChildren".isNull).show
}
}
Project is on IntelliJ
Thank you a lot