首页 > 解决方案 > 粘合 etl 作业 - 使用 create_dynamic_frame.from_options 获取 s3 子文件夹

问题描述

我正在创建 AWS Glue ETL 作业,但在文件检索方面遇到了一些障碍。

似乎以下代码仅获取根文件夹 2017 中的文件,而不再获取。有没有办法在其中包含所有子文件夹和文件?

dyf = glueContext.create_dynamic_frame.from_options(
    's3',
    {"paths": [
        's3://bucket/2017/'
        ]},
    "json",
    transformation_ctx = "dyf")

标签: pythonamazon-web-servicesapache-sparkpysparkaws-glue

解决方案


找到了解决这个问题的方法,看起来字典接受更多参数,我需要的是“递归”。您还可以使用“排除项”排除某些模式。

来源https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-connect.html#aws-glue-programming-etl-connect-s3

dyf = glueContext.create_dynamic_frame.from_options(
    's3',
    {
        "paths": [
            's3://bucket/2017/'
        ],
        "recurse" : True
    },
    "json",
    transformation_ctx = "dyf")


推荐阅读