如何在 RDD[(String, Int)] 上的 saveAsTextFile 时删除记录周围的括号? [英] How to remove parentheses around records when saveAsTextFile on RDD[(String, Int)]?
本文介绍了如何在 RDD[(String, Int)] 上的 saveAsTextFile 时删除记录周围的括号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 saveAsTextFile(path)
以便稍后将输出保存为文本文件以将结果导入数据库.输出看起来像这样:
I'm using saveAsTextFile(path)
in order to save output as text file in later to import the result to DB. The output looks something like this:
(value1, value2)
如何去掉括号?
推荐答案
您可以尝试以下非常基本的:
You can try the following which is very basic:
rdd.map(x => x._1 + "," + x._2).saveAsTextFile(path)
您只需将 RDD[(A,B)] 映射到 RDD[String] 并保存.
You just map your RDD[(A,B)] to an RDD[String] and save it.
这篇关于如何在 RDD[(String, Int)] 上的 saveAsTextFile 时删除记录周围的括号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文