title: How to pass data as a tuple into an rdd in Spark using Scala
body: <p>I have set of coordinates (x, y) as my data in a csv file. I want to pass these x and y into an RDD[(Double, Double)] as tuples and name it points. I have tried the following but for some reason I get an error saying. "Constructor cannot be instantiated to expected type, found: Array[T], required: String".</p>
  
  <pre><code>// Load the data
  val data = sc.textFile("data.csv")
  
  // Read the data as an RDD[(Double, Double)]
  val points = data.map(line =&gt; line.split(",").map{ case Array(x, y) =&gt; (x.toDouble, y.toDouble)} )
  </code></pre>
  
  <p>EDIT : Is there any way I can filter these points so that I can handle values that are null (if x or y or both are null in the dataset)? In essence I want to check if the tuple always contains 2 elements. I tried something like this </p>
  
  <p><code>val points = data.map(line =&gt; line.split(",").filter(!_.isEmpty)).map{ case Array(x, y) =&gt; (x.toDouble, y.toDouble)}.filter(_.size &gt; 1)</code> </p>
  
  <p>but I get an error Type mismatch, expected: (Double, Double) => Boolean, actual: (Double, Double) => Any </p>