Q:

How to put a quote at beginning and end of an RDD data type?

I am looking to put quotes around what is in a RDD data type. So, I have a text file and it’s loaded up into a RDD.  Here is the Scala code:
val file: String = "file:///data/book/starwars"
val bookStarWarsRDD = sc.textFile(file);

The text file is really just plan text of a star wars story, like Return of the Jedi.  I am looking to place a quote on the very first word and the very last word, like:
"A long time ago in a galaxy far, far away...

Then, at the very end place a quote on the last word (or the very end of the story), like:
...and the saga continues. The end.”

How can I do this with a RDD?

A:

For RDD use:
  val myDF = Seq(("Sentence1 something. Sentence2 something")).toDF("text")

  // You may have to adjust index of text column by replacing x(0) with x(index in ur case)
  val test = myDF.rdd.map{ case  (x) => (x(0) , "\"" + x(0) + "\"") } 
  test.foreach(println)

prints: 
(Sentence1 something. Sentence2 something,"Sentence1 something. Sentence2 something")

If you can use dataframe: 
val myDF = Seq(("Sentence1 something. Sentence2 something")).toDF("text")

val withQuotes = myDF.withColumn("textWithQuotes",concat(lit("\""),col("text"),lit("\""))  )
withQuotes.show(false)
scala> withQuotes.show(false)
+----------------------------------------+------------------------------------------+
|text                                    |textWithQuotes                            |
+----------------------------------------+------------------------------------------+
|Sentence1 something. Sentence2 something|"Sentence1 something. Sentence2 something"|
+----------------------------------------+------------------------------------------+ 

