错误代码:DelimitedTextMoreColumnsThanDefined Azure 数据工厂

Error code: DelimitedTextMoreColumnsThanDefined Azure Data Factory

我正在尝试将数据从 csv 文件复制到 Azure 数据工厂中的 sql table 这是我的 CSV 文件类型 属性

        "typeProperties": {
            "location": {
                "type": "AzureBlobStorageLocation",
                "fileName": "2020-09-16-stations.csv",
                "container": "container"
            },
            "columnDelimiter": ",",
            "escapeChar": "\",
            "firstRowAsHeader": true,
            "quoteChar": "\""

我收到以下错误:

ErrorCode=DelimitedTextMoreColumnsThanDefined,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Error found when processing 'Csv/Tsv Format Text' source '2020-09-16-stations.csv' with row number 2: found more columns than expected column count 11.,Source=Microsoft.DataTransfer.Common,'

这是第 2 行

0e18d0d3-ed38-4e7f,Station2,Mainstreet33,,12207,Berlin,48.1807,11.4609,1970-01-01 01:00:00+01,"{""openingTimes"":[{""applicable_days"":96,""periods"":[{""startp"":""08:00"",""endp"":""20:00""}]},{""applicable_days"":31,""periods"":[{""startp"":""06:00"",""endp"":""20:00""}]}]}"

我认为最后一列 JSON 查询在这种情况下造成了麻烦。当我查看数据时,它看起来不错:

我认为 "quoteChar": "\"" 可以防止最后一列出现问题。我不知道为什么我在 运行 调试

时会收到此错误

这是因为此值 "{""openingTimes"":[{""applicable_days"":96,""periods"":[{""startp"":""08:00"",""endp"":""20:00""}]},{""applicable_days"":31,""periods"":[{""startp"":""06:00"",""endp"":""20:00""}]}]}" 包含多个逗号,而您的 columnDelimiter 是“,”,这导致该值被拆分为多个列。所以你需要改变你的columnDelimiter。

尝试设置转义字符 = "(双引号)。这会将每对双引号视为实际的单引号,不会将它们视为字符串中的“引号字符”,因此您最终会有一个看起来像这样的字符串(系统知道这是一个单一的字符串,而不是它必须拆分的东西):

{"openingTimes":[{"applicable_days":96,"periods":[{"startp":"08:00","endp":"20:00"}]},
{"applicable_days":31,"periods":[{"startp":"06:00","endp":"20:00"}]}]}