Load data infile ignore last line?

Hi,

I have a csv file which I am using to populate my table … the file looks like this

This is the data, I will ignore this line when inserting
john, smith, 25
mike, jones, 19
kelly, smith, 22
This line I don’t want to add

I use the following to load my data …

LOAD DATA INFILE 'myfile.csv'
INTO TABLE mytable
  FIELDS TERMINATED BY ','
  LINES TERMINATED BY '\\r\
'
  IGNORE 1 LINES;

All works good, but is there any way to IGNORE the LAST LINE ‘This line I don’t want to add’ ???

Thanks

nope, not without editing the file in some way, and if you’re going to do that, then you might as well just remove that line yourself

I don’t know of a way either, but if you have an ID column that is auto incremented, you can always delete the last row in the table (this is all in theory, no idea if it would actually work)

DELETE FROM mytable WHERE ID = MAX(ID)