Convert a simple one line string to RDD in Spark Convert a simple one line string to RDD in Spark python python

Convert a simple one line string to RDD in Spark


try using List as parameter:

sc.parallelize(List(line)).collect()

it returns

res1: Array[String] = Array(hello,world)


The below code works fine in Python

sc.parallelize([line]).collect()['Hello, world']

Here we are passing the parameter "line" as a list.