【发布时间】:2016-02-02 05:44:24
【问题描述】:
请向我建议如何在 map reduce 程序中将输出文件格式(part-r-00000)(默认文件格式)更新为另一种文件格式,如 csv 或 txt 文件格式。
【问题讨论】:
-
你试过了吗?
-
是的,我试过但没用。 :(
我需要这个来生成报告
请向我建议如何在 map reduce 程序中将输出文件格式(part-r-00000)(默认文件格式)更新为另一种文件格式,如 csv 或 txt 文件格式。
【问题讨论】:
你可以这样做:
hdfs dfs -cat /path/in/hdfs/part* |hdfs dfs -put - /chosen/path/in/hdfs/name_of_file.txt
或
hdfs dfs -cat /path/in/hdfs/part* |hdfs dfs -put - chosen/path/in/hdfs/name_of_file.csv
另一种方法是-getmerge,它复制到本地,但你需要将-copyFromLocal 回hdfs,但它的目的是改变你的文件格式:
hdfs dfs -getmerge /path/in/hdfs/part* /path/in/local/file_name.format
hdfs dfs -copyFromLocal /path/in/local/file_name.format /path/in/hdfs/archive/
【讨论】:
一种方法是您可以使用 hadoop 的 put 命令将 part-r-00000 文件复制到 xyz.txt 文件。 像 hdfs dfs -put part-r-00000 to xyz.txt
【讨论】: