【问题标题】:Moving and merging directories in hdfs在 hdfs 中移动和合并目录
【发布时间】:2016-05-06 18:21:39
【问题描述】:

我正在更改 hdfs 目录结构。 目前如下:

.../customers/customers1/2016-05-16-10/lots_of_files1.csv
.../customers/customers2/2016-05-16-10/lots_of_files2.csv
.../customers/customers3/2016-05-16-10/lots_of_files1.csv
.../customers/customers4/2016-05-16-10/...
.../customers/customers5/2016-05-16-10/...
.../customers/customers6/2016-05-16-10/...
.../customers/customers7/2016-05-16-10/...

我想摆脱客户(1-7):

.../customers/2016-05-16-10/lots_of_files1.csv
.../customers/2016-05-16-10/lots_of_files2.csv
.../customers/2016-05-16-10/lots_of_files1(1).csv

我想使用蛇咬 python hdfs 库,但出现了很多边缘情况: 1. 同一日期可能出现多次。 2. csv的名称可能出现多次,但数据不同,也必须移动。

您如何以最简洁的方式实现它?

【问题讨论】:

    标签: python hadoop hdfs snakebite


    【解决方案1】:

    如果您不担心保留文件名,您可以使用 Apache Drill 轻松完成。就像是 Apache Drill 支持通过 SQL 读写文件。 像

    这样的东西
    create table dfs.`/myfolder/customers/2016-05-16-10` select * from dfs.`/myfolder/customers` where dir1 = '2016-05-16-10';
    

    /*/2016-05-16-10 中的所有文件都将写入目标表。

    https://drill.apache.org/docs/

    【讨论】:

    • 如何处理同名的csv? @vgunnu
    • 将该文件夹中的所有文件合并到新文件中。类似于 Hive
    猜你喜欢
    • 1970-01-01
    • 2016-12-10
    • 2020-08-28
    • 2014-03-10
    • 2016-05-13
    • 1970-01-01
    • 1970-01-01
    • 2013-05-29
    • 1970-01-01
    相关资源
    最近更新 更多