gpt4 book ai didi

azure - 如何让 Azure 数据工厂循环访问文件夹中的文件

转载 作者:行者123 更新时间:2023-12-03 22:05:31 26 4
gpt4 key购买 nike

我正在查看下面的链接。

https://azure.microsoft.com/en-us/updates/data-factory-supports-wildcard-file-filter-for-copy-activity/

我们应该能够在文件夹路径和文件名中使用通配符。如果我们单击“事件”并单击“源”,我们会看到此 View 。

我想循环浏览几个月的任何一天,所以它应该是这样的 View 。

enter image description here

当然,这实际上行不通。我收到的错误如下:ErrorCode: 'PathNotFound'。消息:“指定的路径不存在。”。给定文件路径和文件名中的特定字符串模式,如何让该工具递归地迭代所有文件夹中的所有文件?谢谢。

最佳答案

I would like to loop through months any days

  • 为此,您可以将两个参数从管道传递给事件,以便可以根据这些参数动态构建路径。 ADF V2 允许您传递参数。

让我们一一开始这个过程:

1。创建一个管道并在其中传递您的月份和日期的两个参数。

注意:如果需要,也可以从其他事件的输出传递此参数。引用:Parameters in ADF
Passing Params to the copy activity through pipeline
2.创建两个数据集。

2.1 接收器数据集 - 此处的 Blob 存储。将其与您的链接服务链接并提供容器名称(确保它存在)。同样,如果需要,它可以作为参数传递。 enter image description here

2.2 源数据集 - Blob 存储再次位于此处或根据您的需要而定。将其与您的链接服务链接并提供容器名称(确保它存在)。同样,如果需要,它可以作为参数传递。 enter image description here
注意:1. 文件夹路径决定数据复制的路径。如果容器不存在,事件将为您创建,如果文件已存在,则默认情况下将覆盖该文件。

2. 如果要动态构建输出路径,请传递数据集中的参数。这里我为数据集创建了两个参数,名为monthcopy和datacopy。

3.在管道中创建复制事件。

通配 rune 件夹路径:

    @{concat(formatDateTime(adddays(utcnow(),-1),'yyyy'),'/',string(pipeline().parameters.month),'/',string(pipeline().parameters.day),'/*')}

where:
The path will become as: current-yyyy/month-passed/day-passed/* (the * will take any folder on one level)

enter image description here enter image description here

测试结果:

enter image description here

管道的 JSON 模板:

{
"name": "pipeline2",
"properties": {
"activities": [
{
"name": "Copy Data1",
"type": "Copy",
"dependsOn": [],
"policy": {
"timeout": "7.00:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": false,
"secureInput": false
},
"userProperties": [],
"typeProperties": {
"source": {
"type": "DelimitedTextSource",
"storeSettings": {
"type": "AzureBlobStorageReadSettings",
"recursive": true,
"wildcardFolderPath": {
"value": "@{concat(formatDateTime(adddays(utcnow(),-1),'yyyy'),'/',string(pipeline().parameters.month),'/',string(pipeline().parameters.day),'/*')}",
"type": "Expression"
},
"wildcardFileName": "*.csv",
"enablePartitionDiscovery": false
},
"formatSettings": {
"type": "DelimitedTextReadSettings"
}
},
"sink": {
"type": "DelimitedTextSink",
"storeSettings": {
"type": "AzureBlobStorageWriteSettings"
},
"formatSettings": {
"type": "DelimitedTextWriteSettings",
"quoteAllText": true,
"fileExtension": ".csv"
}
},
"enableStaging": false
},
"inputs": [
{
"referenceName": "DelimitedText1",
"type": "DatasetReference"
}
],
"outputs": [
{
"referenceName": "DelimitedText2",
"type": "DatasetReference",
"parameters": {
"monthcopy": {
"value": "@pipeline().parameters.month",
"type": "Expression"
},
"datacopy": {
"value": "@pipeline().parameters.day",
"type": "Expression"
}
}
}
]
}
],
"parameters": {
"month": {
"type": "string"
},
"day": {
"type": "string"
}
},
"annotations": []
}
}

SINK 数据集的 JSON 模板:

{
"name": "DelimitedText1",
"properties": {
"linkedServiceName": {
"referenceName": "AzureBlobStorage1",
"type": "LinkedServiceReference"
},
"annotations": [],
"type": "DelimitedText",
"typeProperties": {
"location": {
"type": "AzureBlobStorageLocation",
"container": "corpdata"
},
"columnDelimiter": ",",
"escapeChar": "\\",
"quoteChar": "\""
},
"schema": []
}
}

源数据集的 JSON 模板:

{
"name": "DelimitedText2",
"properties": {
"linkedServiceName": {
"referenceName": "AzureBlobStorage1",
"type": "LinkedServiceReference"
},
"parameters": {
"monthcopy": {
"type": "string"
},
"datacopy": {
"type": "string"
}
},
"annotations": [],
"type": "DelimitedText",
"typeProperties": {
"location": {
"type": "AzureBlobStorageLocation",
"folderPath": {
"value": "@concat(formatDateTime(adddays(utcnow(),-1),'yyyy'),dataset().monthcopy,'/',dataset().datacopy)",
"type": "Expression"
},
"container": "copycorpdata"
},
"columnDelimiter": ",",
"escapeChar": "\\",
"quoteChar": "\""
},
"schema": []
}
}

关于azure - 如何让 Azure 数据工厂循环访问文件夹中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57531466/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com