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

Home » Public Forums » archive » extrac subarrays
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
extrac subarrays [message #89716] Wed, 19 November 2014 12:26 Go to next message
lucesmm is currently offline  lucesmm
Messages: 26
Registered: October 2014
Junior Member
I have a big file that I read as a string array and there are various sub arrays within it. I can detect where they start by using "Where" but I don't know when they end (They all have different # rows)
I need to extract them as a float array separately

Any help?

------------------------------------------------------------ ---
Header
coment
coment
coment
more info
...
Fist array
unit unit unit unit unit unit
0.24 0.18 0.13 0.69 0.46 0.07
0.83 0.77 0.14 0.61 0.15 0.20
0.50 0.02 0.16 0.39 0.33 0.63
0.20 0.74 0.23 0.37 0.69 0.68
0.02 0.13 0.24 0.06 0.45 0.56
0.64 0.50 0.88 0.31 0.12 0.93
0.77 0.49 0.99 0.26 0.70 0.92
0.86 0.97 0.12 0.97 0.78 0.23
0.54 0.51 0.90 0.03 0.93 0.25
0.34 0.66 0.86 0.30 0.39 0.67
1.00 0.95 0.53 0.89 0.74 0.93
0.39 0.71 0.03 0.37 0.53 0.35
0.77 0.55 0.92 0.94 0.83 0.89
second array
unit unit unit unit unit unit
0.67 0.58 0.62 0.73 0.11 0.21
0.87 0.03 0.16 0.13 0.24 0.92
0.86 0.71 0.91 0.13 0.53 0.54
0.90 0.71 0.22 0.92 0.89 0.60
0.05 0.49 0.92 0.59 0.16 0.24
0.41 0.25 0.56 0.74 0.17 0.81
0.39 0.48 0.42 0.03 0.75 0.80
0.29 0.15 0.28 0.17 0.31 0.63
0.93 0.81 0.89 0.83 0.19 0.57
0.14 0.31 0.51 0.45 0.99 0.88
0.38 0.38 0.17 0.97 0.88 0.16
0.71 0.38 0.70 0.13 0.60 0.70
0.57 0.48 0.70 0.00 0.19 0.12
1.00 0.90 0.64 0.13 0.97 0.19
0.78 0.41 0.61 0.05 0.43 0.52
0.09 0.41 0.61 0.83 0.69 0.06
0.39 0.11 0.91 0.27 0.69 0.02
0.52 0.32 0.74 0.51 0.37 0.85
Third array
unit unit unit unit unit unit
0.41 0.81 0.43 0.77 0.99 0.36
0.28 0.63 0.63 0.84 0.17 0.08
0.50 0.03 0.40 0.93 0.60 0.30
0.59 0.02 0.12 0.44 0.17 0.61
0.21 0.93 0.24 0.02 0.55 0.70
0.10 0.44 0.40 0.29 0.30 0.82
0.03 0.23 0.67 0.80 0.80 0.49
0.78 0.18 0.95 0.06 0.70 0.67
0.66 0.02 0.92 0.37 0.15 0.87
0.53 0.71 0.99 0.18 0.72 0.46
---------------------------------------------------------
Re: extrac subarrays [message #89717 is a reply to message #89716] Wed, 19 November 2014 12:32 Go to previous messageGo to next message
rryan%stsci.edu is currently offline  rryan%stsci.edu
Messages: 16
Registered: October 2014
Junior Member
If you can detect them with where, then why can't you just loop over the results of where?

;or some such line
g=where(line eq 'unit unit unit...',n)

for i=0,n-2 do begin
data=lines[g(i):g(i+1)]

;now parse data accordingly

endfor





On Wednesday, November 19, 2014 3:26:22 PM UTC-5, lucesmm wrote:
> I have a big file that I read as a string array and there are various sub arrays within it. I can detect where they start by using "Where" but I don't know when they end (They all have different # rows)
> I need to extract them as a float array separately
>
> Any help?
>
> ------------------------------------------------------------ ---
> Header
> coment
> coment
> coment
> more info
> ...
> Fist array
> unit unit unit unit unit unit
> 0.24 0.18 0.13 0.69 0.46 0.07
> 0.83 0.77 0.14 0.61 0.15 0.20
> 0.50 0.02 0.16 0.39 0.33 0.63
> 0.20 0.74 0.23 0.37 0.69 0.68
> 0.02 0.13 0.24 0.06 0.45 0.56
> 0.64 0.50 0.88 0.31 0.12 0.93
> 0.77 0.49 0.99 0.26 0.70 0.92
> 0.86 0.97 0.12 0.97 0.78 0.23
> 0.54 0.51 0.90 0.03 0.93 0.25
> 0.34 0.66 0.86 0.30 0.39 0.67
> 1.00 0.95 0.53 0.89 0.74 0.93
> 0.39 0.71 0.03 0.37 0.53 0.35
> 0.77 0.55 0.92 0.94 0.83 0.89
> second array
> unit unit unit unit unit unit
> 0.67 0.58 0.62 0.73 0.11 0.21
> 0.87 0.03 0.16 0.13 0.24 0.92
> 0.86 0.71 0.91 0.13 0.53 0.54
> 0.90 0.71 0.22 0.92 0.89 0.60
> 0.05 0.49 0.92 0.59 0.16 0.24
> 0.41 0.25 0.56 0.74 0.17 0.81
> 0.39 0.48 0.42 0.03 0.75 0.80
> 0.29 0.15 0.28 0.17 0.31 0.63
> 0.93 0.81 0.89 0.83 0.19 0.57
> 0.14 0.31 0.51 0.45 0.99 0.88
> 0.38 0.38 0.17 0.97 0.88 0.16
> 0.71 0.38 0.70 0.13 0.60 0.70
> 0.57 0.48 0.70 0.00 0.19 0.12
> 1.00 0.90 0.64 0.13 0.97 0.19
> 0.78 0.41 0.61 0.05 0.43 0.52
> 0.09 0.41 0.61 0.83 0.69 0.06
> 0.39 0.11 0.91 0.27 0.69 0.02
> 0.52 0.32 0.74 0.51 0.37 0.85
> Third array
> unit unit unit unit unit unit
> 0.41 0.81 0.43 0.77 0.99 0.36
> 0.28 0.63 0.63 0.84 0.17 0.08
> 0.50 0.03 0.40 0.93 0.60 0.30
> 0.59 0.02 0.12 0.44 0.17 0.61
> 0.21 0.93 0.24 0.02 0.55 0.70
> 0.10 0.44 0.40 0.29 0.30 0.82
> 0.03 0.23 0.67 0.80 0.80 0.49
> 0.78 0.18 0.95 0.06 0.70 0.67
> 0.66 0.02 0.92 0.37 0.15 0.87
> 0.53 0.71 0.99 0.18 0.72 0.46
> ---------------------------------------------------------
Re: extrac subarrays [message #89718 is a reply to message #89717] Wed, 19 November 2014 12:44 Go to previous message
lucesmm is currently offline  lucesmm
Messages: 26
Registered: October 2014
Junior Member
On Wednesday, November 19, 2014 12:32:32 PM UTC-8, rryan%s...@gtempaccount.com wrote:
> If you can detect them with where, then why can't you just loop over the results of where?
>
> ;or some such line
> g=where(line eq 'unit unit unit...',n)
>
> for i=0,n-2 do begin
> data=lines[g(i):g(i+1)]
>
> ;now parse data accordingly
>
> endfor
>
>
>
>
>
> On Wednesday, November 19, 2014 3:26:22 PM UTC-5, lucesmm wrote:
>> I have a big file that I read as a string array and there are various sub arrays within it. I can detect where they start by using "Where" but I don't know when they end (They all have different # rows)
>> I need to extract them as a float array separately
>>
>> Any help?
>>
>> ------------------------------------------------------------ ---
>> Header
>> coment
>> coment
>> coment
>> more info
>> ...
>> Fist array
>> unit unit unit unit unit unit
>> 0.24 0.18 0.13 0.69 0.46 0.07
>> 0.83 0.77 0.14 0.61 0.15 0.20
>> 0.50 0.02 0.16 0.39 0.33 0.63
>> 0.20 0.74 0.23 0.37 0.69 0.68
>> 0.02 0.13 0.24 0.06 0.45 0.56
>> 0.64 0.50 0.88 0.31 0.12 0.93
>> 0.77 0.49 0.99 0.26 0.70 0.92
>> 0.86 0.97 0.12 0.97 0.78 0.23
>> 0.54 0.51 0.90 0.03 0.93 0.25
>> 0.34 0.66 0.86 0.30 0.39 0.67
>> 1.00 0.95 0.53 0.89 0.74 0.93
>> 0.39 0.71 0.03 0.37 0.53 0.35
>> 0.77 0.55 0.92 0.94 0.83 0.89
>> second array
>> unit unit unit unit unit unit
>> 0.67 0.58 0.62 0.73 0.11 0.21
>> 0.87 0.03 0.16 0.13 0.24 0.92
>> 0.86 0.71 0.91 0.13 0.53 0.54
>> 0.90 0.71 0.22 0.92 0.89 0.60
>> 0.05 0.49 0.92 0.59 0.16 0.24
>> 0.41 0.25 0.56 0.74 0.17 0.81
>> 0.39 0.48 0.42 0.03 0.75 0.80
>> 0.29 0.15 0.28 0.17 0.31 0.63
>> 0.93 0.81 0.89 0.83 0.19 0.57
>> 0.14 0.31 0.51 0.45 0.99 0.88
>> 0.38 0.38 0.17 0.97 0.88 0.16
>> 0.71 0.38 0.70 0.13 0.60 0.70
>> 0.57 0.48 0.70 0.00 0.19 0.12
>> 1.00 0.90 0.64 0.13 0.97 0.19
>> 0.78 0.41 0.61 0.05 0.43 0.52
>> 0.09 0.41 0.61 0.83 0.69 0.06
>> 0.39 0.11 0.91 0.27 0.69 0.02
>> 0.52 0.32 0.74 0.51 0.37 0.85
>> Third array
>> unit unit unit unit unit unit
>> 0.41 0.81 0.43 0.77 0.99 0.36
>> 0.28 0.63 0.63 0.84 0.17 0.08
>> 0.50 0.03 0.40 0.93 0.60 0.30
>> 0.59 0.02 0.12 0.44 0.17 0.61
>> 0.21 0.93 0.24 0.02 0.55 0.70
>> 0.10 0.44 0.40 0.29 0.30 0.82
>> 0.03 0.23 0.67 0.80 0.80 0.49
>> 0.78 0.18 0.95 0.06 0.70 0.67
>> 0.66 0.02 0.92 0.37 0.15 0.87
>> 0.53 0.71 0.99 0.18 0.72 0.46
>> ---------------------------------------------------------
Well
I was just doing Where(file EQ First array), Where(file EQ Tenth array)

and also I don't want all the sub arrays stored
let's say I want the first and the tenth (there are like 50 sub arrays in the file)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: N3 (authomatic correction of intensity in MRI data)
Next Topic: Reversing y-axis using label_date

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

Current Time: Wed Oct 08 07:14:10 PDT 2025

Total time taken to generate the page: 0.00455 seconds