我的要求是将 Datalake 文件夹中的文件名与 .CSV 文件中的文件名进行比较,如果文件名匹配,那么我想复制这些文件,如果文件名不匹配,那么我想将这些文件名存储在数据湖中的 .CSV 文件。
请帮忙。
您可以通过以下3个步骤来实现要求,即从csv文件和ADLS文件夹中获取文件名,过滤匹配和不匹配的文件名(从文件夹中),最后进行相应的复制操作。
第 1 步:
get metadata
活动从 ADLS 文件夹中获取文件名列表(sample1.csv、sample2.csv、sample3.csv、sample4.csv)。创建指向您的文件夹的数据集并使用 child items
作为字段列表。look up
从 csv 文件中获取文件名(sample1.csv、sample2.csv、sample5.csv、sample6.csv)。步骤2
items- @activity('list of files in folder').output.childItems
condition- @contains(string(activity('filenames present in csv').output.value),item().name)
items- @activity('list of files in folder').output.childItems
condition- @not(contains(string(activity('filenames present in csv').output.value),item().name))
第三步:
现在,用于每个活动将每个文件复制到另一个位置。我将第 1 个项目的值用作
@activity('getting matching files').output.Value
。在其中,我配置了一个复制活动来复制每个项目的当前活动(即文件名)。
filename
的参数。我从复制数据源设置传递了它的值 (@item().name),如下所示。
["sample3.csv", "sample4.csv"]
。每个项目的值为 @activity('getting unmatched files').output.Value
。append variable
,其值为 @item().name
。@join(variables('filenames'),'
')
#the values will be joined using newline(\n).
#Using \n directly in dynamic content would not work as it will be taken as \\n.
#So change it in pipeline json as in above reference image.
no quote character
。输出:
我尝试了与上述相同的步骤,只是我的查找是 SQL Server 表中的值列表,并且我尝试将其与 ADLS 中文件夹中的 parquet 文件列表进行匹配(而不是示例中的 .csv 文件) 。但我遇到了如下错误:
“‘query’操作输入中的‘from’属性值为‘Object’类型。该值必须是一个数组。”