[Thread Prev][Thread Next][Index]

Re: determine number of rows in an ascii file



Hi Steve,
There are often a number of solutions.  It was pointed out to me
that what I suggested works fine as long as ULLAT doesn't have
missing data, in which case   let n = `ullat[i=@ngd]  would give us
a smaller value than the number of lines in the file.  Spawning a Unix
command is a fine solution, actually, combined with some string
manipulation functions, to compute nlines in a file

yes? LET a = {SPAWN: "wc grid.dat"}
yes? LIST a
             VARIABLE : {SPAWN: "wc grid.dat"}
             X        : 1
        "       3      15     142 grid.dat"


    ! Function STRFLOAT converts the first
    ! number in the string to a float
yes? LIST STRFLOAT(a)
             VARIABLE : STRFLOAT(A)
             X        : 1
          3.000

yes? LET nlines = STRFLOAT(a) - 1
yes? LIST nlines
             VARIABLE : STRFLOAT(A) - 1
             X        : 1
          2.000



Steve Knox wrote:
Thanks, I was hoping there was a solution other than using a Unix program- eg wc - l  as was suggested by another user.

Steve

-- 
  Steve Knox
  Natural Resource Ecology Laboratory
  Colorado State University
  Fort Collins, CO 80523-1499

  


[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement