【发布时间】:2022-01-06 19:47:09
【问题描述】:
我有一个流程,我想编辑 csv 表中的列并将“,”替换为“。”
我该怎么做?因为logicApp中的replace函数表达式不返回列:
当我使用替换功能时,它要求我获取完整的正文。 我要编辑的详细信息列在哪里可用:
我应该如何替换详细信息栏中的“,”?
【问题讨论】:
标签: replace azure-logic-apps logical-operators
我有一个流程,我想编辑 csv 表中的列并将“,”替换为“。”
我该怎么做?因为logicApp中的replace函数表达式不返回列:
当我使用替换功能时,它要求我获取完整的正文。 我要编辑的详细信息列在哪里可用:
我应该如何替换详细信息栏中的“,”?
【问题讨论】:
标签: replace azure-logic-apps logical-operators
例如,我将此作为我从存储帐户中检索的示例 .csv 文件。
首先,我像您一样使用 Parse CSV 文件,然后初始化并使用 Append the string variable 连接器获取 Productsname 列。最后,使用替换函数表达式将 ' , ' 替换为 ' 。 '。
注意:我使用了“|”以下 productsname 变量供将来使用。
这是我的逻辑应用工作流程
组合连接器表达式:-
split(replace(variables('Productname'),',','.'),'|')
输出:
这是我的工作流程,您可以参考:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "@split(replace(variables('Productname'),',','.'),'|')",
"runAfter": {
"For_each_2": [
"Succeeded"
]
},
"type": "Compose"
},
"For_each_2": {
"actions": {
"Append_to_string_variable": {
"inputs": {
"name": "Productname",
"value": "@{items('For_each_2')?['Productname']}|"
},
"runAfter": {},
"type": "AppendToStringVariable"
}
},
"foreach": "@body('Parse_CSV')",
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "Foreach"
},
"Get_blob_content_(V2)": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "get",
"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/files/@{encodeURIComponent(encodeURIComponent('JTJmY29udGFpbmVyMjQwOCUyZlByb2R1Y3RzLmNzdg=='))}/content"
},
"metadata": {
"JTJmY29udGFpbmVyMjQwOCUyZlByb2R1Y3RzLmNzdg==": "/container2408/Products.csv"
},
"runAfter": {},
"type": "ApiConnection"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "Productname",
"type": "string"
}
]
},
"runAfter": {
"Parse_CSV": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Parse_CSV": {
"inputs": {
"body": {
"content": "@{base64(body('Get_blob_content_(V2)'))}",
"headers": "Productid,Productname"
},
"host": {
"connection": {
"name": "@parameters('$connections')['plumsail']['connectionId']"
}
},
"method": "post",
"path": "/flow/v1/Documents/jobs/ParseCsv"
},
"runAfter": {
"Get_blob_content_(V2)": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {
"$connections": {
"value": {
"azureblob": {
"connectionId": "/subscriptions/<subscription id>/resourceGroups/<Your resource group name>/providers/Microsoft.Web/connections/azureblob",
"connectionName": "azureblob",
"id": "/subscriptions/<subscription id>/providers/Microsoft.Web/locations/northcentralus/managedApis/azureblob"
},
"plumsail": {
"connectionId": "/subscriptions/<subscription id >/resourceGroups/<Your resource group name>/providers/Microsoft.Web/connections/plumsail",
"connectionName": "plumsail",
"id": "/subscriptions/<subscription id>/providers/Microsoft.Web/locations/northcentralus/managedApis/plumsail"
}
}
}
}
}
【讨论】:
我用了items函数express,直接做了。
@replace(item()?['details'],',','')
这有点奇怪,起初它不起作用,但现在它起作用了。
【讨论】: