SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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 ...

    Code MySQL:

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

    Thanks

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by chemicaluser View Post
    ...is there any way to IGNORE the LAST LINE 'This line I don't want to add' ????
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chemicaluser View Post
    All works good, but is there any way to IGNORE the LAST LINE 'This line I don't want to add' ????
    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)
    Code MySQL:
    DELETE FROM mytable WHERE ID = MAX(ID)
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •