Convert a simple one line string to RDD in Spark
48,938
try using List as parameter:
sc.parallelize(List(line)).collect()
it returns
res1: Array[String] = Array(hello,world)
Author by
poiuytrez
Updated on July 09, 2022Comments
-
poiuytrez almost 2 years
I have a simple line:
line = "Hello, world"
I would like to convert it to an RDD with only one element. I have tried
sc.parallelize(line)
But it get:
sc.parallelize(line).collect() ['H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd']
Any ideas?