且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

spark rdd saveAsTextFile保存为文件

更新时间:2022-09-19 19:43:32

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)"]












本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/7767609.html,如需转载请自行联系原作者