For your reference:

val d1 = textFile.map(line => {
      val fileds = line.split(",")
      ((fileds(0),fileds(1)), fileds(2).toDouble)
    })

    val d2 = d1.reduceByKey(_+_)
    d2.foreach(println)


2014-08-28 20:04 GMT+08:00 MEETHU MATHEW <meethu2...@yahoo.co.in>:

> Hi all,
>
> I have an RDD  which has values in the  format "id,date,cost".
>
> I want to group the elements based on the id and date columns and get the
> sum of the cost  for each group.
>
> Can somebody tell me how to do this?
>
>
> Thanks & Regards,
> Meethu M
>

Reply via email to