Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Find highest and lowest numerical values for columns in a file

by lidden (Curate)
on Jun 24, 2011 at 17:14 UTC ( [id://911277]=note: print w/replies, xml ) Need Help??


in reply to Find highest and lowest numerical values for columns in a file

Go trough the file and remember what is the smallest and largest number in each column. Something like this (untested):

my $min_col_2 = 1_000_000; # Something large enough my $max_col_2 = 0; # Something small enough my $min_col_3 = 1_000_000; # Something large enough my $max_col_3 = 0; # Something small enough while(<>){ if(/^ZZ/){ my @array = split; if($min_col_2 > $array[1]){ $min_col_2 = $array[1]; } if($max_col_2 < $array[1]){ $max_col_2 = $array[1]; } # Snip } }

To get the step size you also have to remember the second smallest number, and look at the difference between that and the smallest when you are done.

  • Comment on Re: Find highest and lowest numerical values for columns in a file
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://911277]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-23 19:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found