英文:
How can I copy files from an input container to an output container using below logic with Azure data factory
问题
你可以如何将文件从 Azure Blob 存储的输入容器复制到输出容器,并根据文件大小将它们分类到三个不同的文件夹中:小于1KB的文件放入1KB文件夹,大小介于1KB到2KB之间的文件放入2KB文件夹,而大于2KB的文件放入大于2KB_More文件夹?
英文:
How can I copy files from an input container to an output container in Azure blob storage, and sort them into three different folders based on their file size, with files less than 1KB going to the 1KB folder, files between 1KB to 2KB going to the 2KB folder, and files larger than 2KB going to the more than 2KB_More folder?
Any one can help on this
答案1
得分: 0
Sure, here's the translation of the provided content:
请使用以下逻辑流程:
- 使用获取元数据活动获取输入容器内的子项目列表
- 使用ForEach活动以子项目列表为输入
- 在ForEach内,使用获取元数据活动获取文件大小
- 使用设置变量活动基于文件大小设置目标路径
- 使用带有动态接收器的复制活动
动态示例:https://stackoverflow.com/questions/71042704/azure-data-factory-dynamic-content-filename-syntax
英文:
Please use the below logical flow :
- use get meta data activity to get child items list within the input container
- use for each activity with child items list as input
- within for each, use get meta data activity to get file size
- use set variable activity to set the destination path based on file size
- use copy activity with dynamic sink
sample for dynamic : https://stackoverflow.com/questions/71042704/azure-data-factory-dynamic-content-filename-syntax
答案2
得分: 0
以下是您要翻译的内容:
在补充**@Nandan**的回答时,上述流程的第四步可以按以下方式完成。
从第二个获取元数据活动中获取文件大小后,首先使用以下表达式将字节转换为KB。
@string(div(activity('Get Metadata2').output.size,1024))
然后在另一个变量中使用if表达式设置文件夹名称,如下所示。
@if(equals(int(variables('size')),0),'1KB',if(equals(int(variables('size')),1),'2KB','2KB_more'))
将此名称用于接收数据集的文件夹名称。
我的结果:
注意: 如果要复制不同类型的文件,最好使用二进制数据集。
英文:
Adding to @Nandan's answer, The 4th step in the above process can be done like below.
After getting file size from second Get meta data activity, first convert the bytes to KB with the below expression.
@string(div(activity('Get Metadata2').output.size,1024))
Then use if expression in another variable set the folder names like below.
@if(equals(int(variables('size')),0),'1KB',if(equals(int(variables('size')),1),'2KB','2KB_more'))
Use this name in the sink dataset foldername.
My Result:
NOTE: If you are copying different types of files, it's better to use a binary datasets for this.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论