scala 写csv文件

val rdd=sc.parallelize(List(("Jack","America","23"),("Mark","China","25"),("Lura","Australia","24")))

import sqlContext.implicits._
val df=rdd.repartition(1).toDF("name","country","age")//写文件的个数为repartition数

df.write.option("header",true).option("encoding", "UTF-8").csv("C:\\Users\\peanut\\Desktop\\myStudent")
posted @ 2020-04-02 17:27  等木鱼的猫  阅读(1891)  评论(0编辑  收藏  举报