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

Home » Public Forums » archive » Q: About reading files into an array without knowing the size.
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: Q: About reading files into an array without knowing the size. [message #5346 is a reply to message #5205] Mon, 06 November 1995 00:00 Go to previous messageGo to previous message
rivers is currently offline  rivers
Messages: 228
Registered: March 1991
Senior Member
In article <DHMELp.JDM@news.dlr.de>, Hermann Mannstein <H.Mannstein@dlr.de> writes:
> David van Kuijk <kuijk@mpi.nl> wrote:
>> Hi
>>
>> One of the nice things of IDL is that it is possible to read whole
>> ASCII-files of data (e.g. floats) into an array in one swoop, without
>> having to go through a while loop which reads all of these numbers one by
>> one. E.g.:
>>
>> OPENR,1, "filename"
>> floatss=FLTARR(10000)
>> READF, 1, floatss
>>
>> What is not so nice is that IDL has to know exactly how many datapoints
>> there are in the file, otherwise not all the data are read, or you get
>> sth like an "End of file encountered"-error. So the size of _floatss_ in
>> the example above should be equal to the number of floats in the
>
> with
> OPENR,1, "filename"
> a=fstat(1)
> floatss=fltarr(a.size/4)
> READF, 1, floatss
>
> you will get what you want, but you have to know, what type of data "filename"
> contains.
> --

This will not work. "a.size/4" would be the number of elements in the array in
a BINARY file, but the original question concerned ASCII files. In and ASCII
file the number of bytes/element is not known in advance, and it may not even
be the same for each array element.

____________________________________________________________
Mark Rivers (312) 702-2279 (office)
CARS (312) 702-9951 (secretary)
Univ. of Chicago (312) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars3.uchicago.edu (Internet)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: 3D velocity field representation
Next Topic: How can I add parameter to curvefit?

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

Current Time: Wed Oct 08 17:18:29 PDT 2025

Total time taken to generate the page: 0.00457 seconds