【发布时间】:2019-02-06 23:35:08
【问题描述】:
我是 spark 编程的新手,我正在将多个 TSV.gz 文件加载到 RDD 或 Dataframes 中。我想计算加载后列之间的选项卡数,并根据以下条件将数据行移动到单独的 RDD 或数据帧。
总列数 = 996
If the number of tab counts = 995 -> move to another RDD or DF
If the number of tab counts < 995 -> move to another RDD or DF
If the number of tab counts > 995 -> move to another RDD or DF
我尝试了以下但返回布尔值
val textFile = sc.textFile("/abc/*.tsv.gz")
textFile.map(line=>line.split("\t"))
val file1 = textFile.filter(line => line.contains("\t").count() > 995)
val file2 = textFile.filter(line => line.contains("\t").count() < 995)
如果能达到同样的效果,请告诉我
谢谢!
【问题讨论】:
标签: scala apache-spark pyspark apache-spark-sql