My SQL statement in MySQL 5.7.44, Windows 10:
drop table if exists test; create table test (col1 VARCHAR(64), col2 VARCHAR(80) ); LOAD DATA LOCAL INFILE "t.csv" INTO TABLE test FIELDS OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' COLUMNS TERMINATED BY ';' LINES TERMINATED BY '\r\n' ; The data:
E605; E507;"A string spanning several lines "some Umlauts in ""üöä"" to show"" escaping last line" E600;"once again" As hexdump:
00000000 45 36 30 35 3b 0d 0a 45 35 30 37 3b 22 41 20 73 |E605;..E507;"A s| 00000010 74 72 69 6e 67 0d 0a 73 70 61 6e 6e 69 6e 67 20 |tring..spanning | 00000020 73 65 76 65 72 61 6c 20 6c 69 6e 65 73 20 22 22 |several lines ""| 00000030 73 6f 6d 65 20 55 6d 6c 61 75 74 73 20 69 6e 20 |some Umlauts in | 00000040 22 22 c3 bc c3 b6 c3 a4 22 22 20 20 74 6f 20 73 |""......"" to s| 00000050 68 6f 77 22 22 0d 0a 65 73 63 61 70 69 6e 67 22 |how""..escaping"| 00000060 22 0d 0a 6c 61 73 74 20 6c 69 6e 65 22 0d 0a 45 |"..last line"..E| 00000070 36 30 30 3b 22 6f 6e 63 65 0d 0a 61 67 61 69 6e |600;"once..again| 00000080 22 0d 0a |"..| 00000083 The error occurs when I add the FIELDS related keywords FIELDS OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"'. Intention is to have VARCHARs either without " and VARCHARs framed in ". But the outer framing "s should not appear in the data.
FIELDSandCOLUMNSsee dev.mysql.com/doc/refman/8.4/en/load-data.html