Re: [PHP] Parsing a large file

2006-01-13 Thread Curt Zirzow
On Fri, Jan 13, 2006 at 04:47:11PM -0600, Jay Paulson wrote: > > On Fri, January 13, 2006 3:33 pm, Jay Paulson wrote: > >> $buf = ""; > > > > Probably better to initialize it to an empty array();... > > Yep right. > > >> while (!feof($fhandle)) { > >> $buf[] = fgets($fhandle); > > > > ...

Re: [PHP] Parsing a large file

2006-01-13 Thread Curt Zirzow
On Fri, Jan 13, 2006 at 04:21:10PM -0600, Richard Lynch wrote: > > If you DO use grep, don't cat the whole file out to grep it... > > grep __filename__ > __newfile__ oops, forgot the expression :) grep findthis __filename__ > __newfile__ -- cat .signature: No such file or directory -- P

Re: [PHP] Parsing a large file

2006-01-13 Thread Richard Lynch
On Fri, January 13, 2006 4:47 pm, Jay Paulson wrote: >> Buffering 10 lines of text in PHP is probably not going to make a >> significant difference... > > This is true. It's what I have written to start with. Basically I'm > just > trying to make sure that I'm not hogging system memory with a hug

Re: [PHP] Parsing a large file

2006-01-13 Thread Jay Paulson
> On Fri, January 13, 2006 3:33 pm, Jay Paulson wrote: >> $buf = ""; > > Probably better to initialize it to an empty array();... Yep right. >> while (!feof($fhandle)) { >> $buf[] = fgets($fhandle); > > ... since you are going to initialize it to an array here anyway. > >> if ($i++ %

Re: [PHP] Parsing a large file

2006-01-13 Thread Richard Lynch
On Fri, January 13, 2006 3:33 pm, Jay Paulson wrote: > $buf = ""; Probably better to initialize it to an empty array();... > while (!feof($fhandle)) { > $buf[] = fgets($fhandle); ... since you are going to initialize it to an array here anyway. > if ($i++ % 10 == 0) { Buffering 10 line

RE: [PHP] Parsing a large file

2006-01-13 Thread Richard Lynch
On Fri, January 13, 2006 8:37 am, Albert wrote: > Wolf wrote: >> I have large log files from a web server (about a gig in size) and >> need >> to parse each line looking for a string, and when encountered push >> that >> line to a new file. I was thinking I could have PHP read in the >> whole >> f

Re: [PHP] Parsing a large file

2006-01-13 Thread Jay Paulson
> I have large log files from a web server (about a gig in size) and need > to parse each line looking for a string, and when encountered push that > line to a new file. I was thinking I could have PHP read in the whole > file, but thinking it could be a major pain since I have about 20 log > file

Re: [PHP] Parsing a large file

2006-01-13 Thread Richard Correia
best way I think is nohup grep -i string log1 log2 log3 ...logx > newfile & This will run this command in background and you can work on other meanwhile. Thanks Richard On 1/13/06, Wolf <[EMAIL PROTECTED]> wrote: > > I have large log files from a web server (about a gig in size) and need > to

Re: [PHP] Parsing a large file

2006-01-13 Thread Stut
Wolf wrote: Windows server, though I may dump it to linux to get my smaller file, however not sure my admin would like that. :) Get a Windows build of grep (and other useful stuff) here: http://unxutils.sourceforge.net/ Albert wrote: cat | grep > Why cat? Sorry, but this is o

Re: [PHP] Parsing a large file

2006-01-13 Thread Wolf
Windows server, though I may dump it to linux to get my smaller file, however not sure my admin would like that. :) Albert wrote: > Wolf wrote: > >>I have large log files from a web server (about a gig in size) and need >>to parse each line looking for a string, and when encountered push that >>

RE: [PHP] Parsing a large file

2006-01-13 Thread Albert
Wolf wrote: > I have large log files from a web server (about a gig in size) and need > to parse each line looking for a string, and when encountered push that > line to a new file. I was thinking I could have PHP read in the whole > file, but thinking it could be a major pain since I have about 2

[PHP] Parsing a large file

2006-01-13 Thread Wolf
I have large log files from a web server (about a gig in size) and need to parse each line looking for a string, and when encountered push that line to a new file. I was thinking I could have PHP read in the whole file, but thinking it could be a major pain since I have about 20 log files to read