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

Home » Public Forums » archive » Re: Format strings with comma separated lists
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: Format strings with comma separated lists [message #15371 is a reply to message #15369] Mon, 10 May 1999 00:00 Go to previous messageGo to previous message
Vapuser is currently offline  Vapuser
Messages: 63
Registered: November 1998
Member
Well, am I'm surprised!

Just for a lark, I tried this

IDL> openw,1,'/tmp/delme.junk'
IDL> v=findgen(20)
IDL> printf,1,v,format='(4(f5.2,:,","))'
(NB, this comes out looking like
0.00, 1.00, 2.00, 3.00,
4.00, 5.00, 6.00, 7.00,
8.00, 9.00,10.00,11.00,
12.00,13.00,14.00,15.00,
16.00,17.00,18.00,19.00 )

IDL> close,1
IDL> openr,1,'/tmp/delme.junk'
IDL> v[*]=0
IDL> print,minmax(v)
0.00000 0.00000
IDL> v=reform(v,4,5)
IDL> help,v
V FLOAT = Array[4, 5]
IDL> readf,1,v
IDL> print,v
0.00000 1.00000 2.00000 3.00000
4.00000 5.00000 6.00000 7.00000
8.00000 9.00000 10.0000 11.0000
12.0000 13.0000 14.0000 15.0000
16.0000 17.0000 18.0000 19.0000
; Or, you can read it into a vector

IDL> v=fltarr(20)
IDL> point_lun,1,0
IDL> readf,1,v
IDL> print,v
0.00000 1.00000 2.00000 3.00000 4.00000 5.00000
6.00000 7.00000 8.00000 9.00000 10.0000 11.0000
12.0000 13.0000 14.0000 15.0000 16.0000 17.0000
18.0000 19.0000
IDL>

Apparently, the short answer is you don't need to use format strings
on input, provided, I guess, the data is homogeneous and with a
constant number of columns(?); IDL understands that you don't want the
comma.


You can even read the data if there isn't a constant number of
columns. I edited the file so that it looked like;

0.00, 1.00, 2.00,
4.00, 5.00, 6.00, 7.00,
8.00, 9.00,10.00,11.00,
12.00,13.00,14.00,15.00,
16.00,17.00,18.00,19.00

and read it with;

IDL> v=fltarr(19)
IDL> readf,1,v
IDL> print,v
0.00000 1.00000 2.00000 4.00000 5.00000 6.00000
7.00000 8.00000 9.00000 10.0000 11.0000 12.0000
13.0000 14.0000 15.0000 16.0000 17.0000 18.0000
19.0000
IDL>

I was going to suggest a combination of string reads and
STR_SEP. Doesn't look like you need it.

(By the was, this is a
IDL> print,!version
{ mipseb IRIX unix 5.1.1 Jul 20 1998} system
)


William


philaldis@geocities.com (Phil Aldis) writes:

> I hoping that someone else understands format strings better than I
> do, because I can't get them to work at all. I was wondering if anyone
> knew how to read a comma delimited list using format strings, such as
>
> Readf, lun, variable, FORMAT='(n(F6.6, :, ","))'
>
> ...this is the way I would think that you should do it but this just
> tells me that end of input record encountered.
>
> Does anyone know how to do it?#
>
> Cheers,
> Phil Aldis

--
William Daffer: 818-354-0161: vapuser@catspaw.jpl.nasa.gov
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Neuronal Network Programming Tool
Next Topic: Plotting using Symbols (Object Graphics only)

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

Current Time: Sat Oct 11 08:42:50 PDT 2025

Total time taken to generate the page: 0.87891 seconds