title: Apache Spark RDD Split "|"
body: <p>I am trying to produce a formatted CSV file from pipe(&quot;|&quot;) delimited file using Apache Spark . input file contains:</p>
  <blockquote>
  <p>apple|ball|cat</p>
  <p>Blacktown| Bela vista| Greenacre</p>
  <p>x|y|z</p>
  </blockquote>
  <p>I am trying with:</p>
  <pre><code>val name= sc.textFile(input.txt&quot;)
  val split=name.map(line=&gt;line.split(&quot;|&quot;)).map( x =&gt; (x(0),x(2)) )
  split.foreach(println)
  </code></pre>
  <p>Output:</p>
  <blockquote>
  <p>(x,y)</p>
  <p>(a,p)</p>
  <p>(B,a)</p>
  </blockquote>
  <p>My required output is:</p>
  <blockquote>
  <p>(apple,cat)</p>
  <p>(Blacktown, Greenacre)</p>
  <p>(x,z)</p>
  </blockquote>