问题描述
我在Data湖中有一个下面的文件夹结构,我想从ParentFolder目录的所有子文件夹中获取所有.csv文件名.我所有的文件都是.csv文件,有没有一种使用Metadata活动的简单方法.
I have a below Folder Structure in Data lake, I want to get all .csv file names from all subfolders of my ParentFolder directory. All my files are .csv files is there a simple approach to do using Metadata activity.
ParentFolder>Year = 2020文件夹
ParentFolder > Year=2020Folder
2020-10-20Folder > 2020-10-20.csv
2020-10-21Folder > 2020-10-21.csv
2020-10-22Folder > 2020-10-22.csv
推荐答案
我已经进行了测试,以成功获取文件名.
I've made a test to get the FileNames successfully.
我创建了与您相同的文件结构.
I created the same file structure as yours.
- 在ADF中,我们可以定义一个Array类型变量,以便以后存储文件名.
- 这是管道的摘要.
在GetMetaData1活动中,让我们定义根文件夹 2020Folder
的数据集.然后,我们使用 Child Items
来获取所有子文件夹.
At the GetMetaData1 activity, let's define a DataSet of the root folder 2020Folder
. Then we use Child Items
to get all the subfolders.
- 在ForEach1活动中,我们可以使用表达式
@activity('Get Metadata1').output.childItems
列出文件夹列表.
- At the ForEach1 activity, we can use the expression
@activity('Get Metadata1').output.childItems
to foreach the Folder list.
- 在ForEach1活动中,我们可以添加动态内容
@item().name
,以将子文件夹名称传递给GetMetadata2活动.然后,我们可以使用GetMetadata2活动从子文件夹中获取Child Items
.
- In the ForEach1 activity, We can add dynamic content
@item().name
to pass the subfolder name to the GetMetadata2 activity. Then we can use the GetMetadata2 activity to get theChild Items
from the subfolder.
- 在Append变量活动中,我们可以使用我们先前定义的数组变量 FileNames 来存储所有文件名.在这里,我们使用表达式
@activity('Get Metadata2').output.childItems [0]
来获取文件名.
- At the Append variable activity, we can use the array variable FileNames we defined previously to store all the filenames. Here we use expression
@activity('Get Metadata2').output.childItems[0]
to get the filename.
- 最后.我们可以定义另一个Array类型变量来存储和查看结果.
我们可以看到数组的输出.
The output we can see the array.
这篇关于获取子文件夹Azure数据工厂中的所有文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!