【问题标题】:in python hdfs Is there a way to use wildcard or regex in the list method?在 python hdfs 有没有办法在列表方法中使用通配符或正则表达式?
【发布时间】:2019-11-07 08:32:07
【问题描述】:

在 linux hadoop fs -ls 我可以使用通配符 (/sandbox/*) 但 pyhon hdfs 客户端列表方法在此作为未知路径失败。在 python-hdfs 中使用通配符有不同的方法吗?

【问题讨论】:

    标签: python regex wildcard python-hdfs


    【解决方案1】:

    找到this,它使用os.walk和fnmatch,并采用它到hadoop_client。

    这里是查找 csv 文件的示例:

    for root, dirs, files in hc.walk(Path):
        for filename in fnmatch.filter(files, '*.csv'):
            print(os.path.join(root, filename))
    

    【讨论】:

      猜你喜欢
      • 2021-03-19
      • 2021-01-02
      • 1970-01-01
      • 1970-01-01
      • 2019-02-11
      • 1970-01-01
      • 1970-01-01
      • 2013-02-26
      • 2022-07-06
      相关资源
      最近更新 更多