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

Home » Public Forums » archive » readf,1,format= ......
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: readf,1,format= ...... [message #57469 is a reply to message #57392] Sun, 09 December 2007 07:49 Go to previous messageGo to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Dec 9, 8:50 am, woo...@interia.pl wrote:
> sorry a type error but nothing change when i use FMTp for both
> (FMT is quite similar)
>
> function read_local ,file
> FMT=
> '(I5,2X,D13.8,2X,D13.8,3X,F8.2,3X,F8.2,3X,F7.2,3X,F7.2,3X,F6 .2,3X,F6.2,3X,F6.2,3X,F6.2,4X,F6.2,3X,F6.2,3X,F6.2,2X,F6.2)'
> spawn, ['wc', '-l', file], result, /noshell
> nlines = long(result(0))
> ttab = MAKE_ARRAY(nlines-5,15,/DOUBLE)
> OPENR,1,file
> line=''
> readf,1,line
> for i=1,nlines-5 do begin
> READF,1,FORMAT=FMT, n,ra,dec, l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12
> ttab[i-1,0]=n & ttab[i-1,1]=ra & ttab[i-1,2]=dec
> ttab[i-1,3]=l1 & ttab[i-1,4]=l2 & ttab[i-1,5]=l3
> ttab[i-1,6]=l4 & ttab[i-1,7]=l5 & ttab[i-1,8]=l6
> ttab[i-1,9]=l7 & ttab[i-1,10]=l8 & ttab[i-1,11]=l9
> ttab[i-1,12]=l10 & ttab[i-1,13]=l11 & ttab[i-1,14]=l12
> endfor
> CLOSE , 1
> print,FORMAT=FMT,ttab[0,*]
> RETURN,ttab
> end

1) I would avoid using l (el) in variable names - hard to read
2) I would use file_lines to count the number of lines
3) I would define a structure and read each line in separately:
ttab = replicate({n:0,ra:0.0D,dec:0.0D,array:fltarr(12)},nlines)
for i=0L, nlines-5 do readf, lun, ttab[i]

Hope this helps!
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Readf
Next Topic: PLOT x and y ranges

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

Current Time: Sat Oct 11 09:45:30 PDT 2025

Total time taken to generate the page: 0.96176 seconds