Spark: How to save a dataframe with headers?

后端 未结 2 951
被撕碎了的回忆
被撕碎了的回忆 2021-01-02 07:10

dataframe.saveasTextFile, saves only the data in a delimited format. How do I save the dataframe with headers in JAVA.

sourceRufFrame.toJavaRDD(         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-02 07:53

    With Spark 2.x,

    df.write.option("header", "true").csv("path")
    

    Cheers

提交回复
热议问题