map对每个元素进行映射
test.txt 1 a1 2 a2 3 a3 d a4 val test = sc.textFile("/user/zhaoja/test/input/test.txt") val a = test.flatMap{line=>line.split('\t')} val b = test.map{line=>line.split('\t')} a.foreach(println) scala> a.take(1).foreach(println) 1 scala> b.take(1)(0)(0) res47: String = 1