3

I have a CSV file with a column contains " as part of the data The file is initially copied in ASF from SFTP location to ADLS in the copy activity I tried adding quotes as the Quote character so my data looks like (this is just an example, the actual file is bigger)

ID ^ Name

"1" ^ "Galaxy 7" "

what breaking the Azure Synapse COPY INTO command is the inches sign (") next to Galaxy 7

I even tried adding \ as an escape character in the data source that outputs the CSV into adls but did not help

always getting same error

Bulk load failed due to invalid column value in CSV data file /dev/switchingdb/avi_1.txt in row 2, column 21.

copy into command

COPY INTO stg.cdm_stg_Switching_DB FROM 'https://prdacrdatalake.dfs.core.windows.net/adf/dev/switchingdb/avi_1.txt'
                WITH (
                        FILE_TYPE = 'CSV'
                    --  ,COMPRESSION = 'gzip'
                        ,FIELDQUOTE ='"'
                        ,FIRSTROW =2
                        ,FIELDTERMINATOR ='^'
                        ,CREDENTIAL = (IDENTITY = 'Managed Identity')
                )       
Ken White
  • 123,280
  • 14
  • 225
  • 444
AviR
  • 31
  • 2

1 Answers1

0

You can try using an escape character in the COPY INTO command.

COPY INTO stg.cdm_stg_Switching_DB FROM 'https://prdacrdatalake.dfs.core.windows.net/adf/dev/switchingdb/avi_1.txt'
    WITH (
        FILE_TYPE = 'CSV',
        FIELDQUOTE = '"',
        ESCAPE = '\\',
        FIRSTROW = 2,
        FIELDTERMINATOR = '^',
        CREDENTIAL = (IDENTITY = 'Managed Identity')
    )

It will tell the COPY to treat the backslash character (\) as an escape character. By using double backslashes (\\), you can include a literal double quote (") within a field without it being interpreted as the closing quote.

Amira Bedhiafi
  • 8,088
  • 6
  • 24
  • 60