Remove consecutive spaces in RDD lines in Spark
<p>My data set after a lot of programmatic clean up looks like this (showing partial data set here). </p>

<pre><code>ABCD        A M@L                             79
BGDA        F D@L                             89
</code></pre>

<p>I'd like to convert this into the following for further Spark Dataframe operations</p>

<pre><code>ABCD,A,M@L,79
BGDA,F,D@L,89


val reg = """/\s{2,}/"""
val cleanedRDD2 = cleanedRDD1.filter(x=&gt; !reg.pattern.matcher(x).matches())
</code></pre>

<p>But this returns nothing. How do i find and replace empty strings with a delimiter?
Thanks!
rt</p>