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\\wWX570279\\Desktop\\myStudent")
原文:https://www.cnblogs.com/ShyPeanut/p/12621179.html