I have a dataframe like below:
+---+-----+-------------------+
| x| y| z|
+---+-----+-------------------+
|xyz|12223|A,123@B,456@C,98765|
|abc|12456| A,123|
+---+-----+-------------------+
I save it as csv:
index.write.csv("D:\\spark\\tmp\\dd2")
two issues here:
Would you like tell me how to save the column name x,y,z to the header of csv please?
You have to use header option:
index.write.option("header", "true").write(path)
How can I save the output to a single file please?
Write single CSV file using spark-csv
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With