Spark读入本地文件后,成为MapPartitionsRDD,可以使用zipWithIndex,转换成ZippedWithIndexRDD:

Spark 读入文件后如何标记行号

 

查看结果,每一行变为二元组“(内容,索引)”,索引从0开始:

(# Apache Spark,0)

("",1)

(Spark is a fast and general cluster computing system for Big Data. It provides,2)

……

相关文章:

  • 2022-02-15
  • 2022-12-23
  • 2021-08-26
  • 2021-08-31
  • 2021-11-13
  • 2022-12-23
  • 2021-10-25
  • 2021-04-10
猜你喜欢
  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2021-08-04
相关资源
相似解决方案