comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: how to find number of lines in an ASCII file?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: how to find number of lines in an ASCII file? [message #12532] Fri, 21 August 1998 00:00 Go to previous message
Paul Krummel is currently offline  Paul Krummel
Messages: 12
Registered: August 1998
Junior Member
Paul Krummel wrote in message <35dba688.0@news>...
> Jason Li wrote in message <6rdfig$756@post.gsfc.nasa.gov>...
>> I have an ASCII text file that contains data in a nice tabular form,
>>
>> 0 28660 1827.1 72.7705 -158.8828 3388.0 22.3846
10.8545
>> 1 28661 1827.7 72.7701 -158.8752 3391.0 21.1213
10.6029
>> 2 28662 1828.3 72.7698 -158.8677 3394.0 19.8743
10.3546
>> .
>> .
>> .
>>
>> I want to read them all and save into an array: data[8, numberOfLines].
But
>> I don't know numberOfLines in the file before hand. What is the most
> efficient
>> way to find that out?
>>
>> On UNIX, I can pass number of lines information back from wc command. Of
>> course the same code won't work a on Mac. Please help.
>
>
> Below are two functions that I use regularly. I have used them on both
> Windows and UNIX and they work fine. They should be platform independent
and
> I find them to be efficient!
> They were originally written by R. Bauer and I have modified them.
>
> Hope this helps
>
> Cheers Paul Krummel
>
Woops! Just noticed that you will also need the routine below called
type.pro. Sorry for that.

Cheers Paul

;+
; NAME:
; TYPE
;
; PURPOSE:
; Finds the type class of a variable.
;
; CATEGORY:
; Programming.
;
; CALLING SEQUENCE:
; Result = TYPE(X)
;
; INPUTS:
; X
; Arbitrary, doesn't even need to be defined.
;
; OUTPUTS:
; Returns the type of X as a long integer, in the (0,11) range.
; 0 Undefined
; 1 Byte
; 2 Integer
; 3 Long integer
; 4 Float
; 5 Double precision
; 6 Complex number
; 7 String
; 8 Structure
; 9 Double complex
; 10 Pointer
; 11 Object reference
;
; PROCEDURE:
; Extracts information from the SIZE function.
;
; EXAMPLE:
; To find the type class of a variable:
; IDL> print,TYPE(7)
; 2
; IDL> print,TYPE(7D)
; 5
; IDL> print,TYPE('7')
; 7
;
; MODIFICATION HISTORY:
; Created 15-JUL-1991 by Mati Meron, University of Chicago.
; Modified 7 November 1997 by Paul Krummel,
; CSIRO Division of Atmospheric Research.
; Added in help message and expanded header
; info (Pointers and Object references).
;
;-
Function Type, x, help=help
;
on_error,2
if keyword_set(help) then begin
doc_library,'TYPE'
endif
;
; ++++
dum = size(x)
return, dum(dum(0) + 1)
;
; ++++
;
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: general ASCII table import (was: how to find number of lines in an ASCII file?)
Next Topic: basic image processing library?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:35:02 PDT 2025

Total time taken to generate the page: 0.13349 seconds