Re: reading long files [message #1442 is a reply to message #1431] |
Mon, 08 November 1993 02:51   |
knipp
Messages: 68 Registered: January 1993
|
Member |
|
|
In article 9nn@organpipe.uug.arizona.edu, rdc@helium.gas.uug.arizona.edu (richard d clark) writes:
>
> A previous post mentions a two pass method of reading the file first
> determining the necessary size of the array and then reading into it. For
> people running on unix systems spawning a 'wc' will accomplish the first
> pass faster than reading it with idl. Our wc returns # lines, # words, and
> # characters in the file so the array dimensions can be calculated by your
...
> Richard Clark
> rclark@lpl.arizona.edu (or the address in the header)
> For the 10,000th time: it's in Astronomical Algorithms by Jean Meeus!
Another way to count just the number of lines in a file (!UNDER UNIX)
is:
awk "END {print NR}" >filename<
Use SPAWN and capture the output in a variable.
A more general way is to count the number of carr.returns in the file:
CR_BYTE = 10b ; (p.e. for UNIX-Systems)
OPENR, UNIT, FILENAME, /GET_LUN
INFO = FSTAT(UNIT)
I = ASSOC(UNIT, BYTARR(INFO.SIZE))
POS = WHERE(I(0) EQ CR_BYTE)
FREE_LUN, UNIT
NOF_LINES = N_ELEMENTS(POS)
Karl
____________________________________________________________ __________________
__ ____ __
/ // _ \ / / Karlheinz Knipp phone: +49 511 - 762 4922
/ // /_/ // / University of Hannover fax: +49 511 - 762 2483
/ // ____// / Institute for Photogrammetry
/ // / / / Nienburger Str.1
/_//_/ /_/ FRG 30167 Hannover 1 email: knipp@ipi.uni-hannover.de
|
|
|