Let's say I have a string that looks like this [abc, def, ghi]
I want to parse the string and convert it to a sequence such that it is like this Seq(abc, def, ghi)
CodePudding user response:
Hi is the string contained in a DataFrame? Or how does Spark come into play?
If it's just plain scala, this should do the trick:
val string = "[abc, def, ghi]"
string
.replace("[", "")
.replace("]", "")
.split(",")
.map(_.trim)
.toSeq