#define a function which takes line and print
def f(line):
print(line)
#building the text file via list
my_list = [['my text line-1'],['line-2 text2 my2'],['some junk line-3']]
#create RDD via list (you have it via
txt_file = sc.parallelize(my_list)
#use for each to call the function and print will work
txt_file.foreach(f)
#if you want each word via line, use flatmap
来了
相关问题 更多 >
编程相关推荐