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

Home » Public Forums » archive » Re: Reading files with unknown amount of data
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: Reading files with unknown amount of data [message #1358 is a reply to message #1357] Thu, 04 November 1993 03:12 Go to previous messageGo to previous message
brau1231 is currently offline  brau1231
Messages: 2
Registered: November 1993
Junior Member
In article <28fbv1$qg6@reznor.larc.nasa.gov>, zawodny@arbd0.larc.nasa.gov (Dr Joseph M Zawodny) writes:
|> >Robert Davis (rdavis@aerospace.aero.org) wrote:
|> >I am trying to read a data file containing an unknown amount of data into
|> >arrays in IDL. I know the format of the data in the file, but not the number
|> >of pieces of data in the file. Currently, I read the file twice; once to
|> >determine the amount of data in the file and then a second time to actually
|> >read the data into an array (now that I know the size of array needed).
|> >Is there a better way to do this (without having to read the file twice)?
|>
|> Use the EOF function in IDL. Try something like this:
|>
|>


That's good, but you can also add entry's to a array.
IDL let grow the array automatically, too.



array=0. ; to initialize a variable called array


openr,lun,filename, /get_lun ; no interest of 'lun's name
point_lun,lun,0 ; but 'lun' know what I mean
; (logical unit number)

while not eof(lun) do begin

;I use mostly
readf,lun,a ; reading the entry of 'lun'

array=[array,a] ; idl set the variable 'array' (if existing)
; to the right dimensions / append one entry
; so-called 'a'
endwhile
close,lun
free_lun,lun


;cut the first entry of the array (array=0.)

array=(1:*)

from now on, the array 'array' has all entries and the right dimension.

--
Rainer Brauckhoff TU-Berlin Germany

E-Mail: brau1231@camillo.fb12.tu-berlin.de
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Calling External programm
Next Topic: Re: Reading files with unknown amount of dat

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

Current Time: Sat Oct 11 06:25:58 PDT 2025

Total time taken to generate the page: 1.04075 seconds