如何使用azure数据工厂将最新的文件夹文件复制到现有表

问题描述 投票:0回答:1

我有一个年月和日期文件夹,在月份文件夹下添加了包含 4 个文件的新日期文件夹,每天添加了一个包含 4 个文件的日期文件夹,我想要将日期文件夹文件更新到我现有的表中。

dataset azure-data-factory dataverse
1个回答
0
投票

要从一堆文件夹中获取最新的文件夹来传输数据,您需要使用数据流活动和获取元数据活动的组合来获取最新的文件夹。

按照以下步骤获取最新文件夹:

  1. 首先使用数据流活动创建一个文件,其中包含容器中所有不同的文件夹路径。 -- 首先进行数据流活动并使用容器添加源文件并使用通配符和文件路径来获取文件路径 enter image description here -- 然后进行聚合转换并按文件路径列进行分组,并使用我们将在进一步使用的文件夹路径创建一个新列。 enter image description here

    Folderpath : split(max(filepath), '/')[2]+'/'+split(max(filepath), '/')[3]+'/'+split(max(filepath), '/')[4]
    enter image description here 数据预览: enter image description here -- 现在将其以 CSV 文件形式存储在存储帐户的另一个容器中。 enter image description here

  2. 此后进行查找以从新创建的文件中获取所有文件夹路径。 enter image description here

  3. 现在创建新变量来存储最新的文件夹路径,如下所示 enter image description here

  4. 现在将lookup的输出传递给foreach以获取每个文件夹的lastmodified数据。 enter image description here

  5. 现在在 foreach 下执行获取元数据活动来获取每个文件夹的 Lastmodified 日期。 enter image description here

  6. 在此之后获取肉数据使用 If 条件来比较最后修改日期使用此表达式

    @greater(activity('Get Metadata1').output.lastModified,variables('templastdate'))
    enter image description here

  7. 在此 if 条件下取两个设置变量。一是更新

    templastdate
    ,二是获取最新的文件夹路径,如下所示: enter image description here enter image description here

现在在 latestfolder 变量中,您将获得最新文件夹。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.