Re: Parsing Tab Delimited file

From: Date: Tue, 26 Oct 2010 13:52:09 +0000
Subject: Re: Parsing Tab Delimited file
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-47437@lists.php.net to get a copy of this message
At 02:56 PM 10/24/2010, Andrés G. Montañez wrote:
Hi Ethan, fist you need to read the file, you could use the file() function which reads the file as an array, being each line an element; the you have to navigate the array and exploding the lines into an array: $data = file('myfile.txt'); foreach ($data AS $row) { $row = explode("\n", trim($row)); var_dump($row); } And there you go. Cheers. On 24 October 2010 16:46, Ethan Rosenberg <ethros@earthlink.net> wrote: Dear list - Thanks for all your help. I have a tab delimited file which I wish to import into a data base.  In MySQL I can use the LOAD DATA command.  As far as I know, that command cannot be used in PHP as a mysqli_query.  As I understand, I have to parse the file and use the INSERT command. How do I do it?  Code samples, please. Thanks. Ethan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Andrés G. Montañez Zend Certified Engineer Montevideo - Uruguay ++++++++
Andres - Sorry for the delay. Thanks. With what you and Jayson sent, it works beautifully. Ethan

« previous php.db (#47437) next »