Support Questions

Find answers, ask questions, and share your expertise

what does the code do RDD.map(e => e.split(",")(1)) in spark with scala?

avatar
Rising Star

Hi,

what does the code do RDD.map(e => e.split(",")(1)) in spark with scala?

I know RDD.map(e => e.split(",")) would split a string with ',' separated. But, I don't get the (1) in the code. Could somebody give me some information on this? I would greatly appreciate your answer. Thanks!

1 ACCEPTED SOLUTION

avatar
Master Mentor

I'm not familiar with Scala but their docs are similar to Java so I would guess it would return the item at the first index of the result array.

View solution in original post

3 REPLIES 3

avatar
Master Mentor

I'm not familiar with Scala but their docs are similar to Java so I would guess it would return the item at the first index of the result array.

avatar
Rising Star

Hi Artem Ervits,

Thank you very much for your valuable time . I tried and it did exactly the same what you said. Once again Thanks!

avatar
Master Mentor

Glad to help, I learned something too about Scala, it was a mutual benefit