Spark SQL - How to write DataFrame to text file?

Viewed 34601

I am using Spark SQL for reading parquet and writing parquet file.

But some cases,i need to write the DataFrame as text file instead of Json or Parquet.

Is there any default methods supported or i have to convert that DataFrame to RDD then use saveAsTextFile() method?

2 Answers
df.repartition(1).write.option("header", "true").csv("filename.csv")
Related