title: How to handle if delimiter appears in data in spark rdd
body: <p>How to handle if my delimiter is present in data when loading a file using spark RDD.</p>
  <p>My data looks like below:</p>
  <pre><code>NAME|AGE|DEP
  Suresh|32|BSC
  &quot;Sathish|Kannan&quot;|30|BE
  </code></pre>
  <p>How to convert this column into 3 columns like below.</p>
  <pre><code>NAME     AGE     DEP
  suresh     32      Bsc
  Sathish|Kannan      30     BE
  </code></pre>
  <p>Please refer the how i tried to load the data.</p>
  <pre><code>scala&gt; val rdd = sc.textFile(&quot;file:///test/Sample_dep_20.txt&quot;,2)
  rdd: org.apache.spark.rdd.RDD[String] = hdfs://Hive/Sample_dep_20.txt MapPartitionsRDD[1] at textFile at &lt;console&gt;:27
  
  
  rdd.collect.foreach(println)
  
  101|&quot;Sathish|Kannan&quot;|BSC
  102|Suresh|DEP
  
  
  scala&gt; val rdd2=rdd.map(x=&gt;x.split(&quot;\&quot;&quot;))
  rdd2: org.apache.spark.rdd.RDD[Array[String]] = MapPartitionsRDD[2] at map at &lt;console&gt;:29
  
  scala&gt; val rdd3=rdd2.map(x=&gt;
       | {
       | var strarr = scala.collection.mutable.ArrayBuffer[String]()
       | for(v&lt;-x)
       | {
       | if(v.startsWith(&quot;\&quot;&quot;) &amp;&amp; v.endsWith(&quot;\&quot;&quot;))
       |   strarr +=v.replace(&quot;\&quot;&quot;,&quot;&quot;)
       | else if(v.contains(&quot;,&quot;))
       |   strarr ++=v.split(&quot;,&quot;)
       | else
       |   strarr +=v
       | }
       | strarr
       | }
       | )
  rdd3: org.apache.spark.rdd.RDD[scala.collection.mutable.ArrayBuffer[String]] = MapPartitionsRDD[3] at map at &lt;console&gt;:31
  
  scala&gt; rdd3.collect.foreach(println)
  ArrayBuffer(101|, Sathish|Kannan, |BSC)
  ArrayBuffer(102|Suresh|DEP)
  </code></pre>