Re: reading lines from a file

From: Date: Tue, 11 Feb 2003 12:59:05 +0000
Subject: Re: reading lines from a file
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-18453@lists.php.net to get a copy of this message
somth like this may be: $f_array = file (FILE_NAME); for ($i=0; $i<count($f_array); $i++) { $arr_str = explode(";", $f_array[$i]); //*********** // work here with $arr_str as array of str elements (if separator ";")/ if else use ereg or other way //*************** } "George Pitcher" <george.pitcher@ingenta.com> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ: news:HHEIKBOENJPJNLHFCCCCAEFMCCAA.george.pitcher@ingenta.com... > Yes, eventually. I want to come up with a good method because this file is > going to be supplied to me on a fairly regular basis. > > George > > > -----Original Message----- > > From: Svensson, B.A.T. (HKG) [mailto:B.A.T.Svensson@lumc.nl] > > Sent: 11 February 2003 10:56 am > > To: George Pitcher; php-windows@lists.php.net > > Subject: RE: [PHP-WIN] reading lines from a file > > > > > > What do you want to do? Parse the file into tab-delimited data > > in order to bulk load it into the database? > > > > > -----Original Message----- > > > From: George Pitcher [mailto:george.pitcher@ingenta.com] > > > Sent: Tuesday, February 11, 2003 11:41 AM > > > To: php-windows@lists.php.net > > > Subject: [PHP-WIN] reading lines from a file > > > > > > > > > Hi, > > > > > > I have a huge file that I want to get into a db format. > > > > > > There are over 5000 records and I need to create fieldnames on the fly. > > > > > > Each record comprises a number of lines (fields) containing 2 elements > > > (fieldname [first 5 chars (which need rtrimming)], value [rest > > of line, some > > > with lots of text]). > > > > > > Some fieldnames are duplicated within a record so I need to > > rename these by > > > using a counter which is reset for each record (there are at least 5 > > > fieldnames that are affected this way - so 5 counters). > > > > > > Some values contain subfields so I need to be able to handle > > these, but this > > > doesn't look frightening. > > > > > > And I would like to end up with an array with keys (fieldnames) > > and values. > > > > > > But I'm stuck at the first hurdle because I can't find out how > > to put a line > > > into a string. > > > > > > Any pointers? > > > > > > George in Oxford > > > > > > > > > === > > > > > > George Pitcher > > > HERON Technical Manager > > > Ingenta plc > > > 23-38 Hythe Bridge Street, Oxford, OX1 2ET > > > T +44 (0)1865 799137 direct > > > T +44 (0)1865 799000 switchboard > > > F +44 (0)1865 799134 > > > E george.pitcher@ingenta.com > > > > > > www.ingenta.com > > > Ingenta: Empowering the exchange of academic and professional content > > > online. > > > > > > > > > -- > > > PHP Windows Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > >

« previous php.windows (#18453) next »