'Spark dataframe save in single file on hdfs location [duplicate]

I have dataframe and i want to save in single file on hdfs location.

i found the solution here Write single CSV file using spark-csv

df.coalesce(1)
    .write.format("com.databricks.spark.csv")
    .option("header", "true")
    .save("mydata.csv")

But all data will be written to mydata.csv/part-00000 and i wanted to be mydata.csv file.

is that possible?

any help appreciate



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source