gpt4 book ai didi

hadoop - 如何将 hadoop 中大文件的前几行复制到新文件?

转载 作者:可可西里 更新时间:2023-11-01 14:11:53 26 4
gpt4 key购买 nike

我在 hdfs bigfile.txt 中有一个大文件。我想将它的前 100 行复制到 hdfs 上的一个新文件中。我尝试了以下命令:

hadoop fs -cat /user/billk/bigfile.txt |head -100 /home/billk/sample.txt

它给了我一个“猫:无法写入输出流”的错误。我在 hadoop 1 上。

还有其他方法吗? (注意:将第一个 100 行复制到本地或 hdfs 上的另一个文件是可以的)

最佳答案

像这样——

hadoop fs -cat /user/billk/bigfile.txt | head -100 | hadoop -put - /home/billk/sample.txt

我相信“猫:无法写入输出流”只是因为 head 在读取其限制后关闭了流。查看有关 hdfs 的 head 的答案 - https://stackoverflow.com/a/19779388/3438870

关于hadoop - 如何将 hadoop 中大文件的前几行复制到新文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22852063/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com