简体   繁体   中英

Scala method toLowerCase in spark

val file = sc.textFile(filePath)
val sol1=file.map(x=>x.split("\t")).map(x=>Array(x(4),x(5),x(1)))
val sol2=sol1.map(x=>x(2).toLowerCase)

In sol1, I have created an Rdd[Array[String]] and I want to put for every array the 3rd string element in LowerCase so call the method toLowerCase which should do that but instead it transform the string in lowercase char??

I assume you want to convert 3rd array element to lower case

val sol1=file.map(x=>x.split("\t"))
             .map(x => Array(x(4),x(5),x(1).toLowerCase))

In your code, sol2 will be the sequence of string, not the sequence of array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM