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

Home » Public Forums » archive » Skip line in reading a 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: Skip line in reading a file [message #71115 is a reply to message #71018] Wed, 26 May 2010 00:34 Go to previous messageGo to previous message
mankoff is currently offline  mankoff
Messages: 131
Registered: March 2004
Senior Member
On May 25, 11:54 pm, Fred <fedef...@gmail.com> wrote:
> Hi to everybody,
> I need to read a file of n columns "namefile", but also I need to
> select only the lines where the variable in column 3, i.e. [2,*], for
> example, has value larger than X.
> I tried this way:
>
> n1=numlines(namefile)
>
> OPENR, 1, namefile
> aaa=fltarr(col,n1)
> readf,1,aaa
> close,1
>
> aa = REFORM(aaa[2,*])
> if aa[2,*] gt X then a[*,*] = aaa[*,*]
>
> The array a should be an array a[col,n2], where n2 is the number of
> the lines where aa[2,*] gt X.
> But
> help,/st,a
> gives an array with columns=col and lines=n1!!!
> So it completes the routine without errors but does not select the
> lines where aa[2,*] gt X.
> I could not use Skipline of readcol, because it skips only the first
> line. There should be an easy way to do it.
> Thanks

a = randomu(seed,3,10) ; 3 col x 10 row array of random values
gd = where(a[2,*] gt 0.5, ngd) ; All rows where 3rd column > 0.5
if ngd gt 0 then aa = a[*,gd] ; subset 1st array

-k.
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Integrator taking vectors as input?
Next Topic: rotate tickname and titles

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

Current Time: Sat Oct 11 10:33:44 PDT 2025

Total time taken to generate the page: 1.27834 seconds