title: Mapping an input file to different RDDs
body: <p>I have a text file consisting of columns of integers. Assuming that I have N number of columns, I need to have N-1 number of PairRDDs. Each PairRDD has one of the 0 to N-2 columns of my file as Key and the last column as Value. Number of columns in my file varies each time I run the program so I don't know the number of RDDs before the run.</p>
  
  <p>Code below gives <code>task not serializable</code> error.</p>
  
  <pre><code>val inputFile = sc.textFile(path).persist();
  for (dim &lt;- 0 to (numberOfColumns - 2)){            
    val temp = inputFile.map(line =&gt; {
      val lines = line.split(',')
      (lines(dim), lines(numberOfColumns - 1))
    })
  }
  </code></pre>
  
  <p>I appreciate any help for solving this issue.</p>