We help IT Professionals succeed at work.

LOAD DATA LOCAL INFILE

Terry Rogers
Terry Rogers asked
on
403 Views
Last Modified: 2012-08-13
I am currently importing the following formatted ASCI file ...

"ON925727/2","eastbro",0.,0.,0,0.,0.,,2007-01-25,0.,-1,0.,,"Chi"
"ON925727/2","eastbro",0.,0.,0,0.,0.,,2007-01-25,0.,-1,1.,,"Win"
"ON925727/2","eastbro",0.,0.,0,0.,0.,,2007-01-25,0.,-1,0.,,"Wor"
"ON925727/2","eastbro",0.,0.,0,0.,0.,,2007-01-25,0.,-1,0.,,"Ald"


With the command ...

LOAD DATA LOCAL INFILE 'F:\\Bill\\files\\bill\\branstk.TXT' INTO TABLE branstk FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n';

This command also however imports the last character in the file (). I believe this is an end of file marker that I am unable to remove from the exporting program.

Is there any parameter I can use in the LOAD DATA syntax to ignore the last line of an import?
Comment
Watch Question

Top Expert 2006

Commented:
You can't skip lines at the end of the file (only at the beginning).  You'll need to either alter the file before you load or find/delete records that you don't want after the fact.
CERTIFIED EXPERT

Commented:
Try setting one of the fields as NOT NULL if possible. That will generate an import error, but it shouldn't make a difference if it is the last line of the file.

Terry RogersIT Senior Engineer

Author

Commented:
mankowitz what do you mean by set one of the fields to NOT NULL ?

The character at the end of the file is not a data value.
Terry RogersIT Senior Engineer

Author

Commented:
Is there a command I can use to delete the last line in a table?
Top Expert 2006
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.