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

Home » Public Forums » archive » Re: String Data 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: String Data file [message #35836] Thu, 31 July 2003 23:57 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Pavel Romashkin wrote:
> This code doesn't seem to work because the first field, a string, reads
> in the entire line and the numerical variables won't have anything to read:
>
> IDL> line = {col1:"a string", col2:0.0, col3:0.0}
> IDL> OPENR, lun, 'untitled.txt', /GET_LUN
> IDL> READF, lun, data
> % READF: Input conversion error. Unit: 100
> File: SCSI data:untitled.txt
> % Execution halted at: $MAIN$
>
> Would work if the string was the last in the line.
> Cheers,
> Pavel
>

I know but if we use a byte array and some calculations it is much easier.

My routine wasn't working because it determines chars und numbers in the
first byte of each line to find out where are comments.
So it hangs because all looked like comments.

If the text column would be the second or later it works fine.

One workaround could be to add a dummy column in front of the text column.


best regards

Reimar








> Justin wrote:
>
>> Use structures. In fact always use structures for everything because
>> Structures Are Your Friends. They'll make your programs elegant.
>>
>> ;Use a structure to specify that each line is a string and two floats
>> line = {col1:"a string", col2:0.0, col3:0.0}
>> num_lines = 100
>> ;Make an array of structures
>> data = REPLICATE(line, num_lines)
>> OPENR, lun, 'yourfile.dat', /GET_LUN
>> ;Read in all the data in one go
>> READF, lun, data
>> FREE_LUN, lun
>> ;Print out some of the data
>> PRINT, data[5].col1, data[7:9].col2, data.col3
>>


--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: BOX_CURSOR
Next Topic: minor glitch in total()

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

Current Time: Wed Oct 08 16:49:22 PDT 2025

Total time taken to generate the page: 0.00411 seconds