>   123|blah|foo|bar|etc
>
> To be formatted like:
>
>   INSERT INTO Table VALUES (123,'blah','foo','bar','etc');

Assuming there are not | in the actual data:

<?php
    $path = "/path/to/file/to/import.txt";
    # A few thousand entries is a bit much to suck in at once, but
    # it's a one-time hack, so who cares?
    $file = file($path) or die("Could not load file");
    while (list(,$line) = each($file)){
        $values = explode('|', $line);
        $query = "insert into into table values($values[0], '$values[1]',
'$values[2]'...";
        mysql_query($query) or die(mysql_error());
    }
?>

You may want to add a line counter and output that with mysql_error() so you
can quickly refer back to your data file to find a broken line...

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to