load data infile woes

Discussion in 'MySQL' started by arunsuriindia, Mar 7, 2007.

  1. #1
    load data infile 'c:/bse/EQ020307.CSV' into table bse fields terminated by ',' lines terminated by '\n' ignore 1 lines (code,name,kind,type,open,high,low,close,last,prevclose,trades,qty,vol,corp)


    all the fields are varchar(45)

    even when i change the filename i get error 1261 which says row 2660 doesn`t contain data for all columns.

    on the last 2 lines of every csv i want to upload

    Thank you
     
    arunsuriindia, Mar 7, 2007 IP
  2. spachev

    spachev Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Look at your files in a HEX editor to see what is going on. On Linux you can yous khexedit or od -c. Sorry, cannot help you much with Windows off the top of my head, I never use it.
     
    spachev, Mar 8, 2007 IP
  3. arunsuriindia

    arunsuriindia Peon

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    after opening it in the hex editor the file seems to be complete
     
    arunsuriindia, Mar 8, 2007 IP
  4. spachev

    spachev Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Double check line terminators. There is a difference between '\r\n' and '\n'.
     
    spachev, Mar 9, 2007 IP
  5. arunsuriindia

    arunsuriindia Peon

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    that doesn`t work
     
    arunsuriindia, Mar 9, 2007 IP
  6. spachev

    spachev Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    What happens if you truncate the last two lines?
     
    spachev, Mar 12, 2007 IP
  7. arunsuriindia

    arunsuriindia Peon

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    load data infile 'c:/bse/EQ230306.CSV' into table bse2007 fields terminated by ',' ENCLOSED BY '' escaped by '' LINES TERMINATED BY '\r\n' ignore 1 lines (code,name,kind,type,open,high,low,close,last,prevclose,trades,qty,vol,misc)

    i used this command
    the last field misc may or may not contain data and is taken care by escaped by ''

    now i get an error 1261 on last lines
    any file i try of this sort i get an error
     
    arunsuriindia, Mar 12, 2007 IP
  8. arunsuriindia

    arunsuriindia Peon

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    the next two lines give me an error
     
    arunsuriindia, Mar 12, 2007 IP
  9. hdpinn

    hdpinn Peon

    Messages:
    48
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Wish I could help, but load data is one of the reasons I created the program Datafeed to MySQL.
     
    hdpinn, Mar 12, 2007 IP
  10. spachev

    spachev Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    I think you'd be better off sanitizing your data first with a simple Perl script or some other way of your choice.
     
    spachev, Mar 12, 2007 IP