How to fix error : ErrorCode=DelimitedTextMoreColumnsThanDefined,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException

149 views Asked by At

Facing an error while to load data from a csv file from fileshare to SQL table.

Error message:

ErrorCode=DelimitedTextMoreColumnsThanDefined, 'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,
Message=Error found when processing 'Csv/Tsv Format Text' source 'file1.csv' with row number 5: found more columns than expected column count 17.,Source=Microsoft.DataTransfer.Common,'

Value of row number 5 is:

KPY,2524YT,PLOTTED,0,2524YT,PLOTTED,2524YT,PLOTTED,NULL,NULL,NULL,NULL,A,2,2,231,ATON,INC.

Quote character is currently set as double quote (""), escape character is currently set as backslash (\)

I tried changing the escape character to double quote, but it didn't help

1

There are 1 answers

4
Rakesh Govindula On

Your csv file has extra , in your last column of that row. As your dataset delimiter also ,, it is taking it as extra column which is causing the above error.

To overcome the above error, first your file should have different delimiter. Copy activity can't handle the row operations. So, use dataflow for that. But dataflow currently does not have support for File share as source.

So, first take a copy activity and copy the file from file share to temp storage like Data lake gen2 or blob storage. Use binary datasets as source and sink for this copy activity.

After that, take dataflow and source dataset should be this dataset with below configurations. Give Pipe(|) as column delimiter and uncheck the First row as header.

enter image description here

This takes all the columns as a single column with a column name like _col0_.

Next, take derived column in dataflow and use below expression on that column to replace the delimiter.

replace(replace({_col0_}, ',', '|'),'ATON|','ATON,')

enter image description here

In sink settings, give settings as one single file and give the filename.

enter image description here

This sink dataset should have below configurations.

enter image description here

This will generate the csv file like below.

enter image description here

Now, after dataflow activity, use another copy activity to copy the above file to your target.

For the source dataset of this copy activity, use another dataset with Pipe(|) delimiter settings like below.

enter image description here

Result in SQL table:

enter image description here