On 26 October 2010 14:52, Ethan Rosenberg <ethros@xxxxxxxxxxxxx> wrote: > 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@xxxxxxxxxxxxx> 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 > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > If you need to break the tab file apart then fgetcsv() is probably going to help. Just use "\t" for the $delimiter. Pretty much. But that's assuming you aren't using a mysql tool to import the data directly. (I do a BULK INSERT in MS SQL). -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php