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 #35844 is a reply to message #35836] Thu, 31 July 2003 13:38 Go to previous messageGo to previous message
Pavel Romashkin is currently offline  Pavel Romashkin
Messages: 166
Registered: April 1999
Senior Member
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

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
>
[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: Fri Oct 10 14:51:29 PDT 2025

Total time taken to generate the page: 0.56982 seconds