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

Home » Public Forums » archive » READ ARRAY and extract the values
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
READ ARRAY and extract the values [message #93129] Fri, 29 April 2016 14:49 Go to next message
Tanvir Hussain is currently offline  Tanvir Hussain
Messages: 2
Registered: August 2013
Junior Member
Hi All

I have a data which is organized in the following way

obj1 12.5
obj1 14.5
obj1 15.4
obj1 14.0
obj1 12.5
obj1 14.5
obj1 15.4
obj1 14.0
obj1 12.5
obj1 14.5
obj1 15.4
obj1 14.0
obj2 12.5
obj2 14.5
obj2 15.4
obj2 14.0
obj2 12.5
obj2 14.5
obj2 15.4
obj2 14.0
obj2 12.5
obj2 14.5
obj2 15.4
obj2 14.0

I want to extract all the values associated with obj1 and write them in a separate array. In a similar way for the obj2. Please help.

Thanks
Tanvir
Re: READ ARRAY and extract the values [message #93130 is a reply to message #93129] Sat, 30 April 2016 23:56 Go to previous messageGo to next message
Sapna Mishra is currently offline  Sapna Mishra
Messages: 66
Registered: December 2015
Member
readcol,"data.dat",obj,value

for i=0; n_elements(obj)-1 begin
if obj(i)='obj1'
forprint,obj(i),value(i),text='obj1.dat',F='(A,1x,F)'
else
forprint,obj(i),value(i),text='obj2.dat',F='(A,1x,F)'

endfor

Then you can store the value of files obj1.dat and obj2.dat in different array using readcol or openwr.
This may be the easiest way, else there might be so many other ways which others can help....

Thanks
Re: READ ARRAY and extract the values [message #93131 is a reply to message #93129] Sat, 30 April 2016 23:59 Go to previous messageGo to next message
Sapna Mishra is currently offline  Sapna Mishra
Messages: 66
Registered: December 2015
Member
On Saturday, April 30, 2016 at 3:19:59 AM UTC+5:30, Tanvir Hussain wrote:
> Hi All
>
> I have a data which is organized in the following way
>
> obj1 12.5
> obj1 14.5
> obj1 15.4
> obj1 14.0
> obj1 12.5
> obj1 14.5
> obj1 15.4
> obj1 14.0
> obj1 12.5
> obj1 14.5
> obj1 15.4
> obj1 14.0
> obj2 12.5
> obj2 14.5
> obj2 15.4
> obj2 14.0
> obj2 12.5
> obj2 14.5
> obj2 15.4
> obj2 14.0
> obj2 12.5
> obj2 14.5
> obj2 15.4
> obj2 14.0
>
> I want to extract all the values associated with obj1 and write them in a separate array. In a similar way for the obj2. Please help.
>
> Thanks
> Tanvir

readcol,"data.dat",obj,value

for i=0; n_elements(obj)-1 do begin
if obj(i)='obj1' then
forprint,obj(i),value(i),text='obj1.dat',F='(A,1x,F)'
else
forprint,obj(i),value(i),text='obj2.dat',F='(A,1x,F)'

endfor

Then you can store the value of files obj1.dat and obj2.dat in different array using readcol or openwr.
This may be the easiest way, else there might be so many other ways which others can help....

Thanks
Re: READ ARRAY and extract the values [message #93132 is a reply to message #93129] Sun, 01 May 2016 00:08 Go to previous messageGo to next message
Sapna Mishra is currently offline  Sapna Mishra
Messages: 66
Registered: December 2015
Member
On Saturday, April 30, 2016 at 3:19:59 AM UTC+5:30, Tanvir Hussain wrote:
> Hi All
>
> I have a data which is organized in the following way
>
> obj1 12.5
> obj1 14.5
> obj1 15.4
> obj1 14.0
> obj1 12.5
> obj1 14.5
> obj1 15.4
> obj1 14.0
> obj1 12.5
> obj1 14.5
> obj1 15.4
> obj1 14.0
> obj2 12.5
> obj2 14.5
> obj2 15.4
> obj2 14.0
> obj2 12.5
> obj2 14.5
> obj2 15.4
> obj2 14.0
> obj2 12.5
> obj2 14.5
> obj2 15.4
> obj2 14.0
>
> I want to extract all the values associated with obj1 and write them in a separate array. In a similar way for the obj2.

readcol,"data.dat",F='(A,1x,F)',obj,value

for i=0; n_elements(obj)-1 do begin
if obj(i)='obj1' then
forprint,obj(i),value(i),text='obj1.dat',F='(A,1x,F)'
else
forprint,obj(i),value(i),text='obj2.dat',F='(A,1x,F)'

endfor

Then you can store the values of files obj1.dat and obj2.dat in different arrays using readcol or openwr.

This may be the easiest way, else there might be so many other ways which others can help....

Regards,
Re: READ ARRAY and extract the values [message #93133 is a reply to message #93129] Sun, 01 May 2016 00:10 Go to previous message
Sapna Mishra is currently offline  Sapna Mishra
Messages: 66
Registered: December 2015
Member
On Saturday, April 30, 2016 at 3:19:59 AM UTC+5:30, Tanvir Hussain wrote:
> Hi All
>
> I have a data which is organized in the following way
>
> obj1 12.5
> obj1 14.5
> obj1 15.4
> obj1 14.0
> obj1 12.5
> obj1 14.5
> obj1 15.4
> obj1 14.0
> obj1 12.5
> obj1 14.5
> obj1 15.4
> obj1 14.0
> obj2 12.5
> obj2 14.5
> obj2 15.4
> obj2 14.0
> obj2 12.5
> obj2 14.5
> obj2 15.4
> obj2 14.0
> obj2 12.5
> obj2 14.5
> obj2 15.4
> obj2 14.0
>
> I want to extract all the values associated with obj1 and write them in a separate array. In a similar way for the obj2.



readcol,"data.dat",F='(A,1x,F)',obj,value

for i=0; n_elements(obj)-1 do begin
if obj(i)='obj1' then
forprint,obj(i),value(i),text='obj1.dat',F='(A,1x,F)'
else
forprint,obj(i),value(i),text='obj2.dat',F='(A,1x,F)'

endfor

Then you can store the values of files obj1.dat and obj2.dat in different arrays using readcol or openwr.

This may be the easiest way, else there might be so many other ways which others can help....

Regards,
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Is there a way to tell if program is running within the IDLDE?
Next Topic: READ array from a file

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

Current Time: Wed Oct 08 09:10:45 PDT 2025

Total time taken to generate the page: 0.00586 seconds