GregTheGeek
Programmer
Hello all,
I am trying to load a CSV into a mySQL table using the LOAD DATA INFILE command. There is (at least) one record that is causing an issue with the load. A text field in the record *contains* quotes and commas.
Example:
The pattern of commas and quotes are exactly as they appear in the file, but the actual data has been altered to protect my job. ;-)
My statement begins as follows:
Any suggestions? Like I said, its seems to be only one record causing this issue, but there may be more in the future. I would really like to avoid manipulating this data before loading it. Is there some way to ignore the record if it causes an error? (Incorrect datetime value, Truncated incorrect INTEGER value, etc)
Thanks in advance!
GTG
I am trying to load a CSV into a mySQL table using the LOAD DATA INFILE command. There is (at least) one record that is causing an issue with the load. A text field in the record *contains* quotes and commas.
Example:
Code:
{...},ABCD,"This is some text in a field. It contains commas "","",and quotes""",Y,{...}
The pattern of commas and quotes are exactly as they appear in the file, but the actual data has been altered to protect my job. ;-)
My statement begins as follows:
Code:
LOAD DATA INFILE 'D:/path/to/file.csv'
INTO TABLE db_Name.Table_Name
FIELDS
TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
ESCAPED BY ''
LINES
TERMINATED BY '\r\n'
IGNORE 6 LINES
Any suggestions? Like I said, its seems to be only one record causing this issue, but there may be more in the future. I would really like to avoid manipulating this data before loading it. Is there some way to ignore the record if it causes an error? (Incorrect datetime value, Truncated incorrect INTEGER value, etc)
Thanks in advance!
GTG