Saving scala RDD into Text file

apache-spark
scala

#1

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:
RDD–>
testResult.take(5).foreach(println) -->
(test1, 123)
(test2, 124)
(test3, 125)
(test4, 126)
(test5, 127)

Saving this RDD into text file using below command :–
testResult.saveAsTextFile(outputFilePath)

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.
Thanks


#2

before save into text file use map transformation .

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

so the output text will be test ,123


#3

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


#4