title: Spark - Rdd String Cleaning/Manipulation
body: <p>I have a <code>spark.rdd.RDD[String] MapPartition</code> which I created with a filter.</p>
  
  <pre><code>val myMapPartition = myTextFile.filter(_.split("\t")(2) == "\"red\"")
  </code></pre>
  
  <p>This filter split my textFile lines by a tab delimiter and checked whether the second element of the resulting array equals "red"</p>
  
  <p><code>myMapPartition.collect()</code> returns an <code>Array</code> of type <code>String</code>. Here is an example:</p>
  
  <pre><code>24344 "someString" "red"
  23421 "someOtherString" "red"
  </code></pre>
  
  <p>I am trying to perform some edit on the strings. Ultimately, I was looking at some string replacement logic, but I tried to concatenate a string first. So I would be looking for something like this:</p>
  
  <pre><code>24344 "someString hello" "red"
  23421 "someOtherString hello" "red"
  </code></pre>
  
  <p>I tried to accomplish this using a <code>map</code>:</p>
  
  <pre><code>val myCleanRdd = myMapPartition.map(_1 =&gt; (_1.concat(" hello")))
  </code></pre>
  
  <p>However, I ended up with:</p>
  
  <pre><code>24344 "someString" "red" hello
  23421 "someOtherString" "red" hello
  </code></pre>
  
  <p>My question is how can I manipulate certain elements of an rdd row? I think the problem is that my rows are considered one <code>String</code>. I am not sure how to properly map this to allow me to focus on individual fields.</p>
  
  <p><strong>DISCLAIMER:</strong> Scala/Spark noob</p>