【问题标题】:how to write customizesd output file format in mapreduce如何在 mapreduce 中编写自定义输出文件格式
【发布时间】:2016-02-02 05:44:24
【问题描述】:


请向我建议如何在 map reduce 程序中将输出文件格式(part-r-00000)(默认文件格式)更新为另一种文件格式,如 csv 或 txt 文件格式。

【问题讨论】:

  • 你试过了吗?
  • 是的,我试过但没用。 :(
    我需要这个来生成报告

标签: hadoop mapreduce hadoop2


【解决方案1】:

你可以这样做:

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,它复制到本地,但你需要将-copyFromLocalhdfs,但它的目的是改变你的文件格式:

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/

【讨论】:

    【解决方案2】:

    一种方法是您可以使用 hadoop 的 put 命令将 part-r-00000 文件复制到 xyz.txt 文件。 像 hdfs dfs -put part-r-00000 to xyz.txt

    【讨论】:

    • 感谢马赫什。实际上,我想保存像 .fileformat. 这样的输出文件
    • 其实,我想像 .fileformat 这样保存输出文件。有没有办法更新输出文件格式。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多