【问题标题】:LogicApp:replace the message in the csv table with a "." for ","逻辑应用程序:将 csv 表中的消息替换为“.”为了 ”,”
【发布时间】:2022-01-06 19:47:09
【问题描述】:

我有一个流程,我想编辑 csv 表中的列并将“,”替换为“。”

我该怎么做?因为logicApp中的replace函数表达式不返回列:

当我使用替换功能时,它要求我获取完整的正文。 我要编辑的详细信息列在哪里可用:

我应该如何替换详细信息栏中的“,”?

【问题讨论】:

    标签: replace azure-logic-apps logical-operators


    【解决方案1】:

    然后我这样做了,然后我看不到我初始化的变量。

    【讨论】:

    • 你不能为每个循环初始化一个变量,尝试在循环外初始化并尝试在 foreach 循环中设置它。
    • 嗨,Swetha,感谢您的回复。我所做的是将变量初始化为字符串。然后在 for each 我设置它。但它只打印完整 csv 的相同值
    • 抱歉!!我已经更新了答案。你能看一下吗
    【解决方案2】:

    例如,我将此作为我从存储帐户中检索的示例 .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"
                    }
                }
            }
        }
    }
    

    【讨论】:

      【解决方案3】:

      我用了items函数express,直接做了。

      @replace(item()?['details'],',','')
      

      这有点奇怪,起初它不起作用,但现在它起作用了。

      【讨论】:

        猜你喜欢
        • 2018-07-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-18
        • 1970-01-01
        • 1970-01-01
        • 2021-12-08
        相关资源
        最近更新 更多