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

Home » Public Forums » archive » Re: Reading free format data
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Reading free format data [message #16103] Mon, 28 June 1999 00:00
Pavel Romashkin is currently offline  Pavel Romashkin
Messages: 166
Registered: April 1999
Senior Member
Hi Calvin,
I had to work on wierd file formats like this and found that the easiest
thing to do is to read such files into string arrays, then convert them
into FLOAT. I used byte conversions to check if I have an alphabetic
character in a string, but in this case it is unnecessary because the third
column is always a string.
I also "optimized" my code in the way that I stored the position in the
file and then tried to read a large piece (FLOAT(2, 200)). If it failed,
then I'd go row by row. If it worked, then I had read a big chunk very
fast. My files were large and this paid off.
Another way is to read FLOAT(2) in a loop, storing the last position in the
file. If the read failes (use on_ioError), then go back to last saved
position and read a string, after which read FLOAT(2) again. But I am
afraid there is no really neat and fast way.
Good luck,
Pavel

Calvin King wrote:

> I am trying to read a free format data file with variable number of
> columns. Some rows (non-sequential) contain 3 columns of data, while the
> others contain 2 columns of data. The first two columns contain FLOAT
> data, and the third column, if present, contains a string.
>
> What is the best way of handling such a data file?
>
> Thanks, in advance, for any help/suggestions!
>
> Calvin King
> Email: cking@sandia.gov
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Zero vector detection in IDL
Next Topic: Reading free format data

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

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

Total time taken to generate the page: 0.00778 seconds