Sang
Sang

Reputation: 31

Scala RDD[(String,String)] to RDD[String]

We are reading a file in UTF_8 as RDD[(String,String)], Need help in converting this to RDD[String].

val textRdd = sparkSession.sparkContext.binaryFiles(filePath,12)
     .mapValues(content => new String(content.toArray(), StandardCharsets.UTF_8))

Upvotes: 0

Views: 62

Answers (1)

Mohana B C
Mohana B C

Reputation: 5487

You just need to extract value from tuple i.e (string, string).

val outRDD = textRdd.map(t=>t._2) // To get first value use t._1

Upvotes: 1

Related Questions