How to export a table dataframe in PySpark to csv?

后端 未结 5 868
半阙折子戏
半阙折子戏 2020-11-27 02:33

I am using Spark 1.3.1 (PySpark) and I have generated a table using a SQL query. I now have an object that is a DataFrame. I want to export this DataFrame

5条回答
  •  Happy的楠姐
    2020-11-27 03:12

    For Apache Spark 2+, in order to save dataframe into single csv file. Use following command

    query.repartition(1).write.csv("cc_out.csv", sep='|')
    

    Here 1 indicate that I need one partition of csv only. you can change it according to your requirements.

提交回复
热议问题