我需要将文本文件加载到spark数据框中,在这里我尝试使用跳过页眉和页脚 DROPMALFORMED
模式,但它不被尊重。
代码:
val df1 = sparkSession.read.format("csv")
.option("header", “true”)
.option("mode", "DROPMALFORMED")
.option("delimiter",";")
.load(“/xxx/xxx/xxxx/test.txt")
//df1.show(false)
文件 test.txt
内容:
04/11/2020
name;age;id
asdildsh;12;1
ram;13;2
oma;23;3
radahea;14;4
hellohow
期望输出:
+--------+----+---+
|name |age |id |
+--------+----+---+
|asdildsh| 12 | 1 |
|ram | 13 | 2 |
|oma | 23 | 3 |
|radahea | 14 | 4 |
+--------+----+---+
1条答案
按热度按时间polkgigr1#
也许这是有用的-