lines = sc.textFile("c:\\data\\test.txt", 2) lines.collect()
lines1 = sc.parallelize(['a', 'b', 'c']) lines2 = sc.parallelize(['d', 'e', 'f']) lines3 = sc.parallelize(['g', 'h', 'i']) lines = lines1.union(lines2).union(lines3) for line in lines.collect(): print(line)
>>> lines1 = sc.parallelize(['a', 'b', 'c']) >>> lines2 = sc.parallelize(['d', 'e', 'f']) >>> lines3 = sc.parallelize(['g', 'h', 'i']) >>> lines = lines1.union(lines2).union(lines3) >>> for line in lines.collect(): ... print(line) ... a b c d e f g h i >>>
lines = sc.parallelize(['螳讌', '覓', '覦一', '豢']) choo = lines.filter(lambda x: "豢" in x) choo.collect()
>>> lines = sc.parallelize(['螳讌', '覓', '覦一', '豢']) >>> choo = lines.filter(lambda x: "豢" in x) >>> choo.collect() ['覦一', '豢'] >>>