Douglas,
Thank you very much for your quick reply. I can see I wasn't clear. I've
got the same result but not in such a readable, professional way as yours.
But that's still not what I need. I have to print all the lines for which
the highest sum of the seventh element for the same fourth element is >= 3
(e.g.) (and the third element is in dopo.csv and the fifth element is not
in nostock.csv). So from:
3,1,R518672,206,HAVCONSTRUCTION,17.99,1,05,17,00
3,1,R518672,305,HAVCASTLE,17.99,1,05,17,00
3,1,R518672,305,HAVRADIORACERS,17.99,1,05,17,00
3,1,R518672,305,STRHOLISTIC,16.29,1,05,17,00
3,1,R518672,305,TLCBARBIESTORY,13.49,1,05,17,00
I have to get:
3,1,R518672,305,HAVCASTLE,17.99,1,05,17,00 # not printed -
$totals =1;
3,1,R518672,305,HAVRADIORACERS,17.99,1,05,17,00 # not printed -
$totals =2;
3,1,R518672,305,STRHOLISTIC,16.29,1,05,17,00 # printed - $totals
=3;
3,1,R518672,305,TLCBARBIESTORY,13.49,1,05,17,00 # printed - $totals
= 4;
because the highest $totals >=3 for $key = "305"
I'm still working on it, trying different ways. Thanks again and have a
great weekend. I really appreciate your help.
Greg
At 04:33 PM 5/26/2000, you wrote:
>>On 05/26/00, "Greg Wardawy <[EMAIL PROTECTED]>" wrote:
>> > but I can't find my way to complete this task. From the following csv file
>> > I need to print just the lines for which the sum of the seventh
>> element for
>> > this same fourth element is >= 3 (e.g.), the third element is in dopo.csv
>> > and the fifth element is not in nostock.csv:
>> > 3,1000000015,R518672,206,HAVCONSTRUCTION,17.99,1,05,17,00
>>
>>just read in all three files, keep a running total
>>on the third and filter out the is/isn't in constraints,
>>then go back and print whatever passes the sum constraint:
>>
>># Assuming all files are opened ok
>># And we remember to close them
>>while (<DOPO>) {
>> chomp;
>> s/,.*//;
>> $dopo{$_}=1;
>>}
>>
>>while (<STOCK>) {
>> chomp;
>> s/,.*//;
>> $stock{$_}=1;
>>}
>>
>>while (<ORD>) {
>> my ($dopo, $key, $stock, $value) = (split /,/)[2,3,4,6];
>> next unless $dopo{$dopo} and !$nostock{$stock}
>> $totals{$key} += $value;
>> # Save in memory? or open file again later?
>> push (@ord_array, $_)
>>}
>>
>>for (@ord_array) {
>> my ($key) = (split /,/)[3];
>> next unless $totals{$key} >= 3;
>> print;
>>}
>>
>>HTH,
>>Douglas Wilson
>>
>>---
>>You are currently subscribed to perl-win32-users as: [EMAIL PROTECTED]
>>To unsubscribe, forward this message to
>> [EMAIL PROTECTED]
>>For non-automated Mailing List support, send email to
>> [EMAIL PROTECTED]
---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]