http://www.perlmonks.org?node_id=742856


in reply to Re^3: Compare fields in a file
in thread Compare fields in a file

If I add a few events to the input, this breaks. Try it with these data:

2550,531,66,10-12-2007 07:03:08.069,2 2549,529,62,10-12-2007 07:03:08.151,1 2550,531,66,10-12-2007 07:03:09.069,1 2549,529,62,10-12-2007 07:03:09.151,2 2550,531,66,10-12-2007 07:03:10.001,6 2550,531,66,10-12-2007 07:03:11.099,7

The output:

2550,531,66,10-12-2007 07:03:08.069,2 2549,529,62,10-12-2007 07:03:09.151,2 2550,531,66,10-12-2007 07:03:10.001,6 2550,531,66,10-12-2007 07:03:11.099,7

Ignore. I misread the specs.

Replies are listed 'Best First'.
Re^5: Compare fields in a file
by johngg (Canon) on Feb 10, 2009 at 19:57 UTC

    Perhaps I've misunderstood the requirement but that output looks as I would have expected.

    • Two events at time 07:03:08, event with amplitude 2 chosen.

    • Two events at time 07:03:09, event with amplitude 2 chosen.

    • A single event at time 07:03:10, the only event (with amplitude 6) chosen.

    • A single event at time 07:03:11, the only event (with amplitude 7) chosen.

    So far as I can tell, that satisfies the requirement "I'd like to keep only the largest magnitude within each second" to the letter.

    Perhaps you could explain further in which way it is "broken."

    Cheers,

    JohnGG

      Perhaps I've misunderstood the requirement (...)

      Oops, no, it seems that it's me who completely misread the OP's requirements.

      Sorry :(