I'm currently looking at this. This particular code creates a file 10-20 times the size of the orginial file. A minor alteration of this code copies the file to the results file.

Basically I think the problem is, is in the preg_match, and I can't think of why that would die when it is placed back into the code.

Any thoughts.





From: "Clarkson, Nick" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: RE: [PHP] HELP please quickly
Date: Wed, 22 Jan 2003 15:21:32 -0000


I managed this bit of code, but I doubt it does exactly what you want, but
it's a start. And just to add to it I couldn't get the preg_match to work -
so that needs sorting. I'm at work, so I'm afraid I can't spend any more
time right now on this. If anyone can help on the preg_match bit (it just
needs to compare/match 2 strings) then could you add to this ? I looked at
the preg_match function on the php site, but I couldn't make head nor tail
of it :o/

Good luck with it

Nick


<?php
// load file1.txt into array
$file1 = file ('./file1.txt');

// open file2.log for read only
$file2 = fopen ("./file2.log", "r");

// open results.txt for write
$results = fopen ("./results.txt", "w");

while (!feof($file2)) {
$buffer = fgets($file2, 4096);
foreach ($file1 as $line_num => $line) {
//if (preg_match ("/$line/", "$buffer")) <- CAN'T GET THIS
TO WORK ;o(
{ fwrite ($results, $buffer); }
}
}
?>


-----Original Message-----
From: Didier McGillis [mailto:[EMAIL PROTECTED]]
Sent: 22 January 2003 14:33
To: [EMAIL PROTECTED]
Subject: RE: [PHP] HELP please quickly


Cool. Thanks for the information. I try and organize my thoughts like that

as well. I dont really need to delete anything, mostly move and copy.

One problem I have run into is my second file seems to be too big. In just
doing a simple count the first file was fine, found my 470 lines. The
second file is 7.1MB and seems to fail telling me "Fatal error: Allowed
memory size of 8388608 bytes exhausted (tried to allocate 81 bytes)"

So it seems to be on hurrdle at a time.




>From: "Clarkson, Nick" <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: RE: [PHP] HELP please quickly
>Date: Wed, 22 Jan 2003 14:15:32 -0000
>
>
>I'm pretty new to PHP so I can't help you with the code per se, but how
>about as an outline;
>
>Open the first file and read values into an array.
>Open the 2nd file and read in the first line.
>Compare each value in the array to see if it occurs in the line from the
>2nd
>file you just read in.
>If it occurs then write that value to the 3rd file
>Repeat until the array ends
>
>File functions are here -> http://www.php.net/manual/en/ref.filesystem.php
>-
>the only one I can't see is the ability to delete a line in a file - at
>least without creating another holding file....very messy that way
>tho...I'll keep looking.
>
>As an exercise to myself I'll try and recreate it using the 2 example files
>below....dunno how long it'll take me tho ;o)
>
>Good luck
>
>Nick
>
>
>-----Original Message-----
>From: Rick Emery [mailto:[EMAIL PROTECTED]]
>Sent: 22 January 2003 13:57
>To: Didier McGillis
>Cc: [EMAIL PROTECTED]
>Subject: Re: [PHP] HELP please quickly
>
>
>In that case, I don't know of any PHP classes to help you.
>----- Original Message -----
>From: "Didier McGillis" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Wednesday, January 22, 2003 7:53 AM
>Subject: Re: [PHP] HELP please quickly
>
>
>No. The numbers are coming from two text files. The first text file is
>the
>
>file that I need to compare against the second file, and if I find one
>match
>
>in the second file, I need to move it to the third file.
>
>
>
>
>
>
> >From: "Rick Emery" <[EMAIL PROTECTED]>
> >Reply-To: "Rick Emery" <[EMAIL PROTECTED]>
> >To: "Didier McGillis"
><[EMAIL PROTECTED]>,<[EMAIL PROTECTED]>
> >Subject: Re: [PHP] HELP please quickly
> >Date: Wed, 22 Jan 2003 07:45:20 -0600
> >
> >Are the numbers coming from a mysql database? If so, mysql can handle
>this
> >chore.
> >
> >----- Original Message -----
> >From: "Didier McGillis" <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: Wednesday, January 22, 2003 7:21 AM
> >Subject: [PHP] HELP please quickly
> >
> >
> >Here is a brief description of what I want to do. I want to use PHP to
> >grab
> >a list of numbers in one file. Check it against a bigger file and strip
> >the
> >ones that match out of the bigger file, into a "holding" file.
> >
> >
> >so here is what it might look like.
> >
> >file1.txt
> >456789
> >456790
> >456791
> >456792
> >456793
> >456794
> >....
> >
> >file2.log
> >some time stamp
> >code=001;number=456784;name=blahblah;date=012403;
> >some time stamp
> >code=001;number=456785;name=blahblah;date=012403;
> >some time stamp
> >code=001;number=456786;name=blahblah;date=012303;
> >some time stamp
> >code=001;number=456789;name=blahblah;date=012503;
> >some time stamp
> >code=001;number=456789;name=blahblah;date=012503;
> >some time stamp
> >code=001;number=456789;name=blahblah;date=012503;
> >some time stamp
> >code=001;number=456789;name=blahblah;date=012503;
> >some time stamp
> >code=001;number=456789;name=blahblah;date=012503;
> >some time stamp
> >code=001;number=456790;name=blahblah;date=012603;
> >some time stamp
> >code=001;number=456791;name=blahblah;date=012703;
> >
> >notice there might be more then one of the same number, I only need one
>so
> >I
> >need to ignore the rest, rip out the time stamp, which is a seperate
>line.
> >
> >file3.txt
> >code=001;number=456789;name=blahblah;date=012503;
> >code=001;number=456790;name=blahblah;date=012603;
> >code=001;number=456791;name=blahblah;date=012703;
> >
> >can anyone help, any suggestions?
> >
> >
> >
> >
> >
> >_________________________________________________________________
> >MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
> >http://join.msn.com/?page=features/virus
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>_________________________________________________________________
>Help STOP SPAM with the new MSN 8 and get 2 months FREE*
>http://join.msn.com/?page=features/junkmail
>
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>This private and confidential e-mail has been sent to you by Egg.
>The Egg group of companies includes Egg Banking plc
>(registered no. 2999842), Egg Financial Products Ltd (registered
>no. 3319027) and Egg Investments Ltd (registered no. 3403963) which
>carries out investment business on behalf of Egg and is regulated
>by the Financial Services Authority.
>Registered in England and Wales. Registered offices: 1 Waterhouse Square,
>138-142 Holborn, London EC1N 2NA.
>If you are not the intended recipient of this e-mail and have
>received it in error, please notify the sender by replying with
>'received in error' as the subject and then delete it from your
>mailbox.
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php


_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


This private and confidential e-mail has been sent to you by Egg.
The Egg group of companies includes Egg Banking plc
(registered no. 2999842), Egg Financial Products Ltd (registered
no. 3319027) and Egg Investments Ltd (registered no. 3403963) which
carries out investment business on behalf of Egg and is regulated
by the Financial Services Authority.
Registered in England and Wales. Registered offices: 1 Waterhouse Square,
138-142 Holborn, London EC1N 2NA.
If you are not the intended recipient of this e-mail and have
received it in error, please notify the sender by replying with
'received in error' as the subject and then delete it from your
mailbox.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to