View RDD contents in Python Spark?

后端 未结 6 921
醉酒成梦
醉酒成梦 2020-11-29 03:40

Running a simple app in pyspark.

f = sc.textFile(\"README.md\")
wc = f.flatMap(lambda x: x.split(\' \')).map(lambda x: (x, 1)).reduceByKey(add)
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 04:25

    In Spark 2.0 (I didn't tested with earlier versions). Simply:

    print myRDD.take(n)
    

    Where n is the number of lines and myRDD is wc in your case.

提交回复
热议问题