title: How do I convert csv file to rdd
body: <p>I'm new to spark. I want to perform some operations on particular data in a CSV record.</p>
  
  <p>I'm trying to read a CSV file and convert it to RDD. My further operations are based on the heading provided in CSV file.</p>
  
  <p>(From comments)
  This is my code so far:</p>
  
  <pre><code>final JavaRDD&lt;String&gt; File = sc.textFile(Filename).cache();
  final JavaRDD&lt;String&gt; lines = File.flatMap(new FlatMapFunction&lt;String, String&gt;() { 
      @Override public Iterable&lt;String&gt; call(String s) { 
      return Arrays.asList(EOL.split(s)); 
      } 
  });
  final String heading=lines.first().toString();
  </code></pre>
  
  <p>I can get the header values like this. I want to map this to each record in CSV file.</p>
  
  <pre><code>final String[] header=heading.split(" "); 
  </code></pre>
  
  <p>I can get the header values like this. I want to map this to each record in CSV file.</p>
  
  <p>In java I’m using <code>CSVReader record.getColumnValue(Column header)</code> to get the particular value. I need to do something similar to that here.</p>