in reply to Re: Text Massage
in thread Text Massage

#columns are tab delimeter
What I have:
0.000000 #delete this line
0.000000 0.000000 0.000000 ..curve 1 256 elements
0.000000 0.000000 0.000000 ..curve 2 256 elements
0.000000 2.566058 1.466319 ..curve 1 256 elements
2.199478 2.199478 3.665797 ..curve 2 256 elements
pattern continues curve 1,2,1,2,1,2...

What I need:
output to text file "A"
0.000000 0.000000 0.000000 ..curve 1 256 elements
blank line
0.000000 2.566058 1.466319 ..curve 1 256 elements
blank line
cont...

output to text file "B"
0.000000 0.000000 0.000000 ..curve 2 256 elements
blank line
2.199478 2.199478 3.665797 ..curve 2 256 elements
blank line
cont...
-------------------------------------------------------
I hope i explained better. This is what the original file looks like:
-------------------------------------------------------
Curve1: UBIN
NumSamples: 1
RepCode: 68
SampleSize: 1024 NumElements: 256
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 2.566058 1.466319 2.199478 2.199478 3.665797 2.199478 2.932637 2.566058 3.299217 2.932637 5.498694 2.932637 4.398956 3.299217 2.199478 2.932637 3.299217 1.466319 2.566058 2.566058 2.932637 2.932637 0.733159 1.099739 2.566058 1.466319 1.832898 1.099739 0.733159 1.466319 2.199478 1.832898 1.832898 1.099739 2.199478 0.000000 0.733159 0.733159 1.466319 1.099739 2.199478 2.566058 3.299217 4.032376 4.765535 5.865274 6.965014 9.164492 11.730549 9.164492 9.897650 13.563448 6.231853 8.064753 5.498694 2.932637 2.199478 1.099739 1.099739 0.733159 0.733159 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.366580 0.000000 0.000000 0.366580 0.366580 0.000000 0.733159 0.366580 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.366580 0.366580 0.366580 0.000000 0.366580 0.000000 0.366580 0.366580 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000

Curve2: LBIN
NumSamples: 1
RepCode: 68
SampleSize: 1024 NumElements: 256
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.733159 0.366580 1.099739 2.199478 3.665797 5.132115 6.231853 7.698173 9.531071 6.965014 11.730549 10.997389 17.962402 10.630810 15.029766 15.396345 8.797913 11.363968 16.496086 9.531071 12.830288 10.630810 14.663187 11.363968 13.563448 8.064753 10.630810 9.531071 13.196867 8.431332 10.264231 10.264231 5.132115 7.698173 14.296606 8.064753 8.797913 5.865274 7.698173 6.231853 7.331594 8.431332 10.264231 6.598433 8.797913 6.598433 7.331594 9.531071 7.331594 4.765535 7.698173 6.231853 7.331594 9.897650 8.431332 14.296606 18.328983 11.730549 13.930027 16.496086 11.363968 10.997389 7.331594 7.331594 5.132115 7.698173 4.765535 5.498694 2.932637 5.132115 4.765535 3.665797 5.865274 4.032376 2.932637 3.665797 5.132115 3.665797 4.398956 4.398956 5.498694 3.665797 2.566058 5.132115 4.398956 2.199478 1.832898 5.132115 5.498694 5.132115 3.299217 1.466319 5.132115 5.865274 4.765535 5.132115 3.299217 4.765535 7.698173 8.064753 8.797913 11.363968 9.164492 11.730549 13.930027 10.997389 9.897650 13.930027 10.630810 11.363968 7.331594 8.431332 6.965014 8.797913 3.299217 7.331594 10.264231 8.064753 9.164492 6.965014 6.598433 8.431332 5.498694 7.698173 9.164492 7.331594 3.665797 5.132115 4.398956 3.299217 1.832898 2.199478 1.466319 0.366580 0.733159 1.099739 0.366580 0.366580 0.366580 0.000000 0.733159 1.099739 0.366580 0.000000 0.000000 0.000000 0.366580 0.000000 0.366580 0.366580 0.000000 0.000000 0.366580 0.000000 0.000000 0.366580 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.366580 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.733159 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000

Frame readOk!!!
Frame Depth = 2.000000
Curve[0]: TIME
NumSamples: 1
RepCode: 68
SampleSize: 4 NumElements: 1
2.000000
Curve1: UBIN
NumSamples: 1
RepCode: 68
SampleSize: 1024 NumElements: 256
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.300065 2.566147 2.966686 3.999977 5.200147 5.166321 4.000022 4.733136 6.767208 6.900260 6.233482 9.399803 6.533770 5.899480 7.800454 6.100563 5.933439 5.700024 3.566949 4.366557 4.066492 7.133698 3.832987 2.233527 3.800410 4.066559 2.066582 2.433072 2.600263 1.933507 2.066537 3.399804 3.033201 3.633331 2.300065 3.699890 1.500435 2.533592 2.833679 3.566816 1.099784 4.299953 4.066492 4.499632 5.833010 9.866812 9.466408 13.266951 14.266081 20.432980 16.966843 20.400425 20.765869 13.433762 11.966038 9.999865 5.633375 3.399915 1.699891 1.699891 1.033246 1.333311 0.366602 0.300087 0.300065 0.300065 0.300065 0.000000 0.366602 0.366602 0.000000 0.600129 0.366580 0.366580 0.300065 0.733204 0.366580 0.366580 0.000000 0.000022 0.000022 0.000022 0.300109 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.300065 0.366580 0.300065 0.000000 0.000000 0.000000 0.000000 0.000022 0.000000 0.366580 0.000022 0.000000 0.366580 0.000000 0.000022 0.000000 0.000000 0.366580 0.000000 0.000000 0.300087 0.000022 0.000000 0.000022 0.366580 0.000000 0.666644 0.366580 0.666644 0.000045 0.366580 0.000000 0.666644 0.366580 0.366580 0.000000 0.000000 0.000022 0.000000 0.000000 0.000000 0.000000 0.000000 0.300065 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000022 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000022 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000

Curve2: LBIN
NumSamples: 1
RepCode: 68
SampleSize: 1024 NumElements: 256
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.333311 0.666667 2.300042 3.700024 6.366556 7.833255 10.133074 12.499809 17.033291 13.266951 21.033066 24.201035 33.566589 21.734161 25.832939 27.700066 18.401161 22.767162 26.098801 21.834278 22.433250 20.233547 22.165562 20.066647 22.866184 20.067806 20.833652 18.833786 22.499474 16.233459 19.266682 17.166252 12.934196 14.000044 21.798801 14.666531 15.099737 11.867058 13.699978 13.433851 12.133028 15.333622 16.566124 9.599459 12.999331 11.700068 14.233324 14.332729 15.433651 12.267597 11.299438 11.033335 15.133898 21.300709 20.134590 24.799671 28.832115 25.234283 28.934151 26.999260 20.966640 19.400093 14.533703 15.433672 10.833946 11.299351 9.566948 9.399914 6.233593 9.633375 7.166321 6.066626 11.266773 7.333377 5.933685 7.867014 7.532811 5.766405 8.600241 8.300154 10.900082 6.666688 4.066537 9.033089 7.999887 3.700225 7.234463 6.332620 8.199432 6.932682 5.700047 3.567017 6.032577 8.866234 7.466295 8.733271 7.200325 7.166521 11.899435 13.166296 15.699888 20.366421 16.066647 19.533165 25.033131 21.800385 18.300308 19.331860 18.133095 17.666107 12.133341 13.533054 14.467209 14.499609 10.201239 15.733738 18.366467 14.366800 16.666622 14.767206 14.100786 16.533634 12.100451 13.699978 15.466206 12.733135 7.266952 8.133030 8.299974 7.800476 2.433161 3.099761 2.366624 0.666689 1.033268 1.399826 0.966731 0.666667 0.666667 0.300065 0.733204 1.399804 0.666667 0.000000 0.000022 0.000022 0.366602 0.000000 0.666644 0.366580 0.000000 0.300065 0.366624 0.000022 0.000022 0.366580 0.366580 0.000000 0.300065 0.300065 0.000000 0.000022 0.000000 0.000000 0.000022 0.300087 0.000000 0.000000 0.000000 0.300065 0.000000 0.666667 0.366580 0.000000 0.300065 0.300065 0.300087 0.366580 0.300065 0.000000 0.000022 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.300065 0.000022 0.000000 0.000000 0.000022 0.000000 0.000000 0.000000 0.366580 0.000000 0.000000 0.000000 0.000000 0.000000 0.366580 0.000000 0.000022 0.000000 0.000022 0.000000 0.000000 0.666644 0.000022 0.000022 0.000000 0.000000 0.000000 0.366580 0.000000 0.300065 0.300065 0.000000 0.000000 0.000022 0.366580 0.000022 0.000000 0.000000 0.733159 0.000000 0.000022 0.000000 0.366580 0.000000 0.000000

Replies are listed 'Best First'.
Re^3: Text Massage
by Marshall (Canon) on Apr 08, 2009 at 07:43 UTC
    I am still unsure as to what you want. To separate the blocks of number is easy.
    #!/usr/bin/perl -w use strict; $| =1; my $curve1_out = 'curve1.out'; my $curve2_out = 'curve2.out'; my $in ='curve12.data'; open (IN, '<', $in) or die "cannot open $in $!"; open (my $c1, '>', $curve1_out) or die "cannot open $curve1_out $!"; open (my $c2, '>', $curve2_out) or die "cannot open $curve2_out $!"; while (<IN>) { if (/^Curve(\d):/.../^\s*$/) { if (defined($1) && $1==1 && /^\d/) {print $c1 "$_\n";}; if (defined($1) && $1==2 && /^\d/) {print $c2 "$_\n"}; } }
    data attached...So what else needs to happen?
      That is what I was trying to accomplish for the past week

      Would you be gracious enough to place comments on your code so that I can understand what is going on.
      Thanks a bunch.

      Dear Marshal,

      That is what I have been trying to accomplish.
      When I run the script, my output files have nothing on them.
      Would you comment the lines of code, so that I can understand the logic and try
      to solve why I am not getting the results you are getting.

      Regards,

      Joe

        Hi Joe!
        I've been away dealing with other problems..its not that I am ignoring you! For example, the Tax man bites tomorrow and I had to deal with that! Ouch!

        More to the Perl point:
        The use of the ... and .. pattern matching operators.

        I've seen the ... op called the "flip-flop" operator. I don't know what these folks would call the .. operator. They are the same except that ... operates on multiple lines and .. operates on a single line.

        Code examples are good so, here we go...!!

        #!/usr/bin/perl -w use strict; while (<DATA>) { print if (/^TITLE:/.../^\s*$/); } __DATA__ TITLE: qasfd asfdikyh6rf76 khlyouyih TITLE: oiqywrot6 09809g808 asdfafTITLE: stuff stuff that doesn't matter [asDFKJKLAFG] ASDFKJAFKLJ TITLE: TITLE ASDFASFD not a title paragraph TITLE: 98797 ABCD EFG __END__ ##### prints: ####### TITLE: qasfd asfdikyh6rf76 khlyouyih TITLE: oiqywrot6 09809g808 asdfafTITLE: TITLE: 98797 ABCD EFG
        The above prints all lines between and inclusive of the lines that start with TITLE and have a blank line. The .. operator does about the same but is restricted to one line instead of multiple lines.

        $1 has to do with first match in the "regex", Regular Expression.

        Think of the ... op as kind of a filter. Once you are inside this "filtered" set of lines or tokens, then you can further filter things to further exclude what you don't want. This is like a funnel that takes in gallons and produces "shot glasses" of output.

        Having said that, I'm not sure that this is the best way for what you are doing. I am actually not quite sure what your app is. If things haven't worked out, post some more info and we will talk about it.