currently i'm new student to scala, Looking for scala coding help in parsing the string to a case class,
case class CategaryIds(id1: Long, id2: Long, id3: Long, secIds: Set[Long])
data looks like below represented as spark RDD
600045,8114,31679,"{1:2:3:4}"
600034,8114,34526,
600056,8114,31679,"{1:2:3:4}"
tried below code, throws exception arrayoutofbund exception and numberformat exception
val fields = line.split(",").map(_.trim);
CategaryIds(fields(0).toLong,fields(1).toLong,fields(2).toLong,fields(3).replace("{","").replace("}", "").split(":").map(_.toLong).toSet)}
If any better way to achieve this, please share it
fields(3)when there is no element at that index, like in the second element of your RDD. - Ton Torres