Saving scala RDD into Text file



Hello everyone,

This is very basic but looks like I am completely confused in this.

question: How to save RDD of tuple into text file without saving data in the form of tuple.
Below are details:
testResult.take(5).foreach(println) -->
(test1, 123)
(test2, 124)
(test3, 125)
(test4, 126)
(test5, 127)

Saving this RDD into text file using below command :–

current output of text file:
(test1, 123)
(test2, 124)
(test3, 125)
(test4, 126)
(test5, 127)

Expected output of text file:
test1, 123
test2, 124
test3, 125
test4, 126
test5, 127

Can someone please help asap.


before save into text file use map transformation .

map(x => (x._1 + “,” + x._2)) .

so the output text will be test ,123


Thank you so much Vani. Dont know why I got confused.