1

When I save this RDD[(String,Double)] as a text file I get:

(Ram is great,1.0)

Can I save into file without these brackets and also can we change this comma and put some other delimiter like tab (\t).

Hence it will look like:

Ram is great    1.0
Peter Neyens
  • 9,770
  • 27
  • 33
Kshitij Kulshrestha
  • 2,032
  • 1
  • 20
  • 27

2 Answers2

3

Map the RDD to a string with the formatting you prefer.

Something like coll.map(x=>s"${x._1}\t${x._2}").saveAsTextFile(file)

Chobeat
  • 3,445
  • 6
  • 41
  • 59
1

It will be like this ->

Suppose RDD name is temp

val required = temp.map(f => f._1+"\t"+f._2).saveAsTextFile(path)

Kshitij Kulshrestha
  • 2,032
  • 1
  • 20
  • 27