title: How to convert RDD[(String, String)] into RDD[Array[String]]?
body: <p>I am trying to append filename to each record in the file. I thought if the RDD is Array it would have been easy for me to do it.  </p>
  
  <p>Some help with converting RDD type or solving this problem would be much appreciated!  </p>
  
  <p>In (String, String) type  </p>
  
  <pre><code>scala&gt; myRDD.first()(1)    
  scala&gt;&lt;console&gt;:24: error: (String, String) does not take parametersmyRDD.first()(1)  
  </code></pre>
  
  <p>In Array(string)  </p>
  
  <pre><code>scala&gt; myRDD.first()(1)    
  scala&gt; res1: String = abcdefgh
  </code></pre>
  
  <p>My function:</p>
  
  <pre><code>def appendKeyToValue(x: Array[Array[String]){
      for (i&lt;-0 to (x.length - 1)) {
          var key = x(i)(0)
          val pattern = new Regex("\\.")
          val key2 = pattern replaceAllIn(key1,"|")
          var tempvalue = x(i)(1)
          val finalval = tempvalue.split("\n")
          for (ab &lt;-0 to (finalval.length -1)){
              val result = (I am trying to append filename to each record in the filekey2+"|"+finalval(ab))
              }  
          }
  }
  </code></pre>