Failed to load CSV file which as line break in quoted column
I am trying to load a CSV file which has a string column in quoted string. Unfortunately I have \n (new line) in the quoted string. Here is the example Cust_id, cust_address, city,zip 1, "1289 cobb parkway Bufford", "ATLANTA",34343 2, "1234 IVY lane Decatur", "ATLANTA",23435 I am trying to use following copy command COPY tempdb.test_cust FROM LOCAL 'test.dat' DELIMITER ',' ENCLOSED BY '"' NO ESCAPE SKIP 1 DIRECT; Above copy script fails with error message vsql:test.vsql:24: ERROR 2035: COPY(tempdb.test_cust): Input record 1 has been rejected (Too few columns found) It appears to me line break in between quoted string is considered as record delimiter. Do you have any solution to load this type of delimited file using COPY?
0
Comments
1, "1289 cobb parkway Bufford", "ATLANTA",34343 2, "1234 IVY lane Decatur", "ATLANTA",23435 awk '!(NR%2){$(NF+1)=";"}1' filename 1, "1289 cobb parkway Bufford", "ATLANTA",34343; 2, "1234 IVY lane Decatur", "ATLANTA",23435;I have placed a record terminator ';' on every alternate line. Step2 Now coming to Vertica, as you have record terminator defined in the csv file now, you can use the record terminator function with the COPY command this way. This should do the trick for you. Note - If doing this in two step might not be a good idea, then there is a package called "External Filter" on Github which we can use to do this in a single COPY command. With external filter you have full access to command line tools while using the COPY command. Hope this helps..