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?

Explorer

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

Accepted Solutions

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

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

Explorer

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!

Mentor

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