csv formatting so it will be readable for mysql

Discussion in 'PHP' started by Edynas, Aug 1, 2006.

  1. #1
    Not the correct place maybe but hope someone knows how to do this

    I have a csv file (in txt) and it is a datafeed and want to input it into my database but the file is not good formatted.
    The description is over several lines and when I use navicat or the normal import function it sees every new line as a new record.

    I need somthing to eliminate the newlines that are not correct and make it so only every new record is on a new line.
    Normally I would do it by hand but this file is over 65000 lines long :(

    Hope this makes sence and someone can help me.

    Edwin
     
    Edynas, Aug 1, 2006 IP
  2. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I would start off by trying to use excel to format it. If this fails then upload it to your server and use the fopen function to go through it line by line and alter the positions of the linebreaks.

    Have you tried uploading it with phpmyadmin? That normally handles most things.
     
    mad4, Aug 1, 2006 IP
  3. Edynas

    Edynas Peon

    Messages:
    796
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #3
    phpmyadmin doesn't work and line by line with over 65,000 lines is a bit ...

    what I have is a file that looks like this

    
    id;title;link;description;price;offerid;image;category;Einde;
    "3";"GEMEY MAYBELLINE MASCARA
    • Ook in waterproof. <a href=""url"">Klik hier voor kleurcodes</a>
    
    EANCODE: 5021044013332";"10.99";"06503-001";"http://www.drogisterij.net/producten/afbeelding/06503-001.jpg";
    
    "Ricils Volum'Express";"####"";
    "4";etc etc
    
    
    Code (markup):
    I almost think it is best to put it all on 1 line and try to figure out how to make a php function that will aalk thru the line and break it every 9th ; it comes across
     
    Edynas, Aug 1, 2006 IP