Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error code: DelimitedTextMoreColumnsThanDefined Azure Data Factory

I am trying to copy data from a csv file to a sql table in Azure Data Factory This is my type property for the CSV file

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

I recieve following error:

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,'

This is row #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""}]}]}"

I think the last column, the JSON query is making trouble in this case. When I view the data it looks fine: enter image description here

I thought exactly the "quoteChar": "\""would prevent that the last column makes problems. I have no idea why I am getting this error while i run debug

like image 693
Amir Avatar asked Nov 15 '25 11:11

Amir


2 Answers

Try setting the escape character = " (a double quote). This should treat each pair of double quotes as an actual single quote and wont consider them as a "Quote Char" within the string, so you will end up with a string that looks like this (and which the system knows is a single string and not something it has to split):

{"openingTimes":[{"applicable_days":96,"periods":[{"startp":"08:00","endp":"20:00"}]},
{"applicable_days":31,"periods":[{"startp":"06:00","endp":"20:00"}]}]}
like image 185
NickW Avatar answered Nov 18 '25 10:11

NickW


This is because this value "{""openingTimes"":[{""applicable_days"":96,""periods"":[{""startp"":""08:00"",""endp"":""20:00""}]},{""applicable_days"":31,""periods"":[{""startp"":""06:00"",""endp"":""20:00""}]}]}" contains several comma and your columnDelimiter is "," which leads to that value is split to several column. So you need to change your columnDelimiter.

like image 45
Steve Zhao Avatar answered Nov 18 '25 12:11

Steve Zhao