Redshift Copy fails due to '\' present in some of the data in my csv file

0

I am trying to copy csv file from S3 to Redshift table. I have few of the columns present in my csv file that contains '' in the data. Below is the sample data:

columnA|columnB|columnC|columnD|columnE

abc|12|xyz|test|hello

lmn|123|pqr|test|bye

jkl|124|deg|test|hi

I am using below command to copy in Redhisft, but it fails:

COPY redshif_schema.redshift_table_name from 's3://bucket/folder/inputfile.csv' access_key_id '<access_id>' secret_access_key '<secret_key>' fillrecord escape delimiter as '|' IGNOREHEADER as 1 ACCEPTANYDATE emptyasnull blanksasnull maxerror 0 ;

When I check raw_line in stl_load_errors table, I see below (2 back slashes):

abc|12|xyz|test|hello

Can someone please help with this?

gefragt vor 3 Jahren2097 Aufrufe
1 Antwort
0

Redshift is interpreting the backslash as an escape since you have specified ESCAPE in your COPY.

You can try:

beantwortet vor 3 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen