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

Home » Public Forums » archive » read a multi-line string in IDL? or, read numeric values sequentially without automatic <CR>?
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: read a multi-line string in IDL? or, read numeric values sequentially without automatic <CR>? [message #87410 is a reply to message #87408] Fri, 31 January 2014 11:33 Go to previous messageGo to previous message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
And if you don't know the number of values in the file a priori, you can do this:

file = 'test.txt'
nLines = FILE_LINES(file)
strA = STRARR(nLines) ;define an array to hold the "raw" data

OPENR, lun, file, /GET_LUN
READF, lun, strA ;read in the "raw" data, i.e., the data as it is in the file
FREE_LUN, lun

strJ = STRJOIN(strA) ;join all the data to one line

nVal = N_ELEMENTS(STRSPLIT(strJ)) ;number of values

arr = FLTARR(nVal) ;an array to hold the numbers

READS, strJ, arr ;read 'em in

cgPlot, arr ;or whatever

Notice that this does not give the same number of elements that you provide. For example, I get 230 values....
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: gridding XYZ to surface: how to blank no data?
Next Topic: Create new variable with subset of 4D array

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

Current Time: Wed Oct 08 19:01:46 PDT 2025

Total time taken to generate the page: 0.00435 seconds