title: adding up a column of a text file using JAVA RDD in spark
body: <p>I'm a newbie in spark. I'm trying to read a textfile, and sum up the total of the third column. I'm a bit confused how to do it with RDD. </p>
  
  <pre><code>public class test2 {
    public static void main(String[] args) {
       String logFile = "textfile.txt"; // Should be some file on your system
  
       JavaSparkContext sc = new JavaSparkContext("local", "Simple App",
              "spark-0.9.1-bin-hadoop2/", new String[]{"test2_jar/test2.jar"});
       JavaRDD&lt;String&gt; logData = sc.textFile(logFile).cache();
       JavaRDD&lt;String&gt; tabbed = logData.flatMap(new FlatMapFunction&lt;String, String&gt;() {
          @Override
          public Iterable&lt;String&gt; call(String s) throws Exception {
              return Arrays.asList(s.split(","));
          }
       });
    }
  }
  </code></pre>
  
  <p>this is as far as i get. How do i get the RDD to access second column after i split it? i know the summation can be done using fold. but i'm not really sure how to do it. </p>