如何使用foreach(println)将下面的代码分隔成diff行:
sc.textFile("/user/edureka_366833/spark/fmapvalue")
.map(_.split('\t'))
.map(a=>(a(0),a(1)))
.flatMapValues(a=>(a.split(':')))
scala>
sc.textFile("/user/edureka_366833/spark/fmapvalue")
.map(_.split('\t')).map(a=>(a(0),a(1)))
.flatMapValues(a=>(a.split(':'))).collect
res5: Array[(String, String)] = Array((0001,a), (0001,b), (0001,c),
(0002,d), (0002,e), (0002,f), (0003,g), (0003,h), (0003,i),
(0004,j), (0004,k), (0004,l))
scala>
sc.textFile("/user/edureka_366833/spark/fmapvalue")
.map(_.split('\t')).map(a=>(a(0),a(1)))
.flatMapValues(a=>(a.split(':')))
.foreach(println)
没有返回任何内容