spark rdd saveAsTextFile保存为文件

sc.parallelize(["one", "two", "two", "three", "three", "three"]).map(lambda x: (x,1)).repartition(1).saveAsTextFile("feature/all.txt")

load方法:

a=sc.textFile("feature/all.txt")
a.collect()

[u"('one', 1)", u"('two', 1)", u"('two', 1)", u"('three', 1)", u"('three', 1)", u"('three', 1)"]

posted @ 2017-11-01 17:38  bonelee  阅读(11726)  评论(0编辑  收藏  举报