I need to load text file into Spark dataframe where I'm trying to skip header and footer using DROPMALFORMED
mode, but its not being honored.
Code:
val df1 = sparkSession.read.format("csv")
.option("header", “true”)
.option("mode", "DROPMALFORMED")
.option("delimiter",";")
.load(“/xxx/xxx/xxxx/test.txt")
//df1.show(false)
File test.txt
content:
04/11/2020
name;age;id
asdildsh;12;1
ram;13;2
oma;23;3
radahea;14;4
hellohow
Desired output:
+--------+----+---+
|name |age |id |
+--------+----+---+
|asdildsh| 12 | 1 |
|ram | 13 | 2 |
|oma | 23 | 3 |
|radahea | 14 | 4 |
+--------+----+---+