Loading ...
Sorry, an error occurred while loading the content.

yanking a group of lines out of a file

Expand Messages
  • kraig1234
    I am brand new to perl and need help. I have a project to read through a file and pull out a section of the file. There is no set size for the section. The
    Message 1 of 5 , Oct 1, 2002
    • 0 Attachment
      I am brand new to perl and need help. I have a project to read
      through a file and pull out a section of the file. There is no set
      size for the section. The sections of the file are separated by 80 *.
      The section should only be pulled out if 2 different comparisons are
      done. For one comparison the values are on the same line (though it
      shows 4 times in every section) and the other is on different lines
      but one line is above the other. Please help me.
    • Charles K. Clarkson
      ... By pull out , Do you mean delete or copy? ... Is the separator 80 * or 80 astericks? ... How big is the file? Can we load the whole file in memory? Or
      Message 2 of 5 , Oct 1, 2002
      • 0 Attachment
        kraig1234 [mailto:kraig1234@...] wrote:

        : I am brand new to perl and need help. I have a project
        : to read through a file and pull out a section of the file.

        By "pull out", Do you mean delete or copy?

        : There is no set size for the section. The sections of the
        : file are separated by 80 *.

        Is the separator "80 *" or 80 astericks?

        : The section should only be pulled out if 2 different
        : comparisons are done. For one comparison the values
        : are on the same line (though it shows 4 times in every
        : section) and the other is on different lines but one
        : line is above the other.

        How big is the file?
        Can we load the whole file in memory?
        Or do we have to step through it line-by-line?
        What specifically are the comparisons?
        Do you know enough perl to any of the code?
        Can you show us what you have so far?
        Can you show us what the file to be searched
        looks like?
      • kraig1234
        ... I mean copy from the orignal file into another file. ... It is 80 astericks. ... The file size varies. The file is the output of the tkprof utility in
        Message 3 of 5 , Oct 2, 2002
        • 0 Attachment
          --- In perl-beginner@y..., "Charles K. Clarkson" <cclarkson@h...>
          wrote:
          > kraig1234 [mailto:kraig1234@y...] wrote:
          >
          > : I am brand new to perl and need help. I have a project
          > : to read through a file and pull out a section of the file.
          >
          > By "pull out", Do you mean delete or copy?
          I mean copy from the orignal file into another file.
          >
          > : There is no set size for the section. The sections of the
          > : file are separated by 80 *.
          >
          > Is the separator "80 *" or 80 astericks?
          It is 80 astericks.

          >
          > : The section should only be pulled out if 2 different
          > : comparisons are done. For one comparison the values
          > : are on the same line (though it shows 4 times in every
          > : section) and the other is on different lines but one
          > : line is above the other.
          >
          > How big is the file?
          The file size varies. The file is the output of the tkprof utility
          in Oracle.
          > Can we load the whole file in memory?
          > Or do we have to step through it line-by-line?
          This is possible I guess but the filesize is a variable.
          > What specifically are the comparisons?
          The comparison is a ratio. I need to find out which section of the
          file has the highest ratio.
          > Do you know enough perl to any of the code?
          This is my introduction. Nothing like baptism by fire, eh?
          > Can you show us what you have so far?
          I have just begun. I do have another section of code that steps
          through the file and pulls out any section that has a keyword.
          Although I have to modify this code so that I am not hardcoding the
          filename.
          > Can you show us what the file to be searched
          > looks like?
          Here is a sample from one of the files. As you can see the sections
          can range in size. The sections that need the ratios are 1) the
          first value after parse compared to the first value after execute and
          2) the total elapsed and total cpu values.

          **********************************************************************
          **********

          SELECT SUM(E.AMOUNT)
          FROM
          ENTRY_RTAB E WHERE E.DETAILACCOUNT_ID = :b1 AND E.WHEN_SETTLED
          <= :b2 AND
          E.WHEN_SETTLED > :b3


          call count cpu elapsed disk query
          current rows
          ------- ------ -------- ---------- ---------- ---------- ---------
          - ----------
          Parse 0 0.00 0.00 0 0
          0 0
          Execute 2 0.00 0.00 0 0
          0 0
          Fetch 2 0.01 0.05 4 10
          0 2
          ------- ------ -------- ---------- ---------- ---------- ---------
          - ----------
          total 4 0.01 0.05 4 10
          0 2

          Misses in library cache during parse: 0
          Optimizer goal: CHOOSE
          Parsing user id: 57 (OPS$IBRETCLR) (recursive depth: 1)

          Rows Execution Plan
          ------- ---------------------------------------------------
          0 SELECT STATEMENT GOAL: CHOOSE
          0 SORT (AGGREGATE)
          0 INDEX GOAL: ANALYZED (RANGE SCAN) OF
          'GIX_ENTRY_DACCT_WHEN_SETTLED' (NON-UNIQUE)

          **********************************************************************
          **********

          BEGIN :p1 := account_balance_reporting.getSumOfCompAcctNegBalances
          ( :p2,
          TO_DATE(:p3,'yyyymmddhh24mi'), 'T' ); END;


          call count cpu elapsed disk query
          current rows
          ------- ------ -------- ---------- ---------- ---------- ----------
          ----------
          Parse 6 0.00 0.00 0 0
          0 0
          Execute 7 4.81 8.09 99490 420451
          0 7
          Fetch 0 0.00 0.00 0 0
          0 0
          ------- ------ -------- ---------- ---------- ---------- ----------
          ----------
          total 13 4.81 8.09 99490 420451
          0 7

          Misses in library cache during parse: 1
          Misses in library cache during execute: 1
          Optimizer goal: CHOOSE
          Parsing user id: 57 (OPS$IBRETCLR)
          **********************************************************************
          **********
        • Charles K. Clarkson
          kraig, I m running short of time. I uploaded a script to get you started. It is inefficient and not commented, but it works. Take a look at it and ask
          Message 4 of 5 , Oct 3, 2002
          • 0 Attachment
            kraig,

            I'm running short of time. I uploaded a script
            to get you started. It is inefficient and not
            commented, but it works. Take a look at it and ask
            questions here, but look at the perl docs first.
            The split function is explained in 'perlfunc'. The
            one I use ( split ' ') is the special case
            mentioned there.

            You can read about many perl functions in the
            file titled 'perlfunc'. I used subroutines to do
            some of the work. You'll want to read 'perlsub'.
            When you see '->' a reference is being used; read
            'perlref'. 'perlre' explains the match operator
            ( m/\Q$separator/ ).

            I used the DATA file handle. You'll probably
            want to open a file instead. Just put a '*' in
            front of the file handle when you pas it to a
            sub.

            The script I wrote is at:
            http://groups.yahoo.com/group/perl-beginner/files/kraig/ratios.pl

            Good luck,


            Charles K. Clarkson
            --
            Head Bottle Washer,
            Clarkson Energy Homes, Inc.
            Small commercial and residential rehabilitation specialists.
            254 968-8328

            CJ Web Work - Solutions for Real Estate Investors.
            972 216-4952

            CJ Web Hosting - Affordable Hosting - Custom Accounts.
            254 968-8328
          • kraig1234
            Charles, Thanks for the reply. I am sorry that I did not respond quicker. I was able to get some code from somewhere else and modify it to meet the needs of
            Message 5 of 5 , Oct 10, 2002
            • 0 Attachment
              Charles,
              Thanks for the reply. I am sorry that I did not respond quicker. I
              was able to get some code from somewhere else and modify it to meet
              the needs of the project. I will post the section of code that I
              used where you placed the file for me.


              --- In perl-beginner@y..., "Charles K. Clarkson" <cclarkson@h...>
              wrote:
              > kraig,
              >
              > I'm running short of time. I uploaded a script
              > to get you started. It is inefficient and not
              > commented, but it works. Take a look at it and ask
              > questions here, but look at the perl docs first.
              > The split function is explained in 'perlfunc'. The
              > one I use ( split ' ') is the special case
              > mentioned there.
              >
              > You can read about many perl functions in the
              > file titled 'perlfunc'. I used subroutines to do
              > some of the work. You'll want to read 'perlsub'.
              > When you see '->' a reference is being used; read
              > 'perlref'. 'perlre' explains the match operator
              > ( m/\Q$separator/ ).
              >
              > I used the DATA file handle. You'll probably
              > want to open a file instead. Just put a '*' in
              > front of the file handle when you pas it to a
              > sub.
              >
              > The script I wrote is at:
              > http://groups.yahoo.com/group/perl-beginner/files/kraig/ratios.pl
              >
              > Good luck,
              >
              >
              > Charles K. Clarkson
              > --
              > Head Bottle Washer,
              > Clarkson Energy Homes, Inc.
              > Small commercial and residential rehabilitation specialists.
              > 254 968-8328
              >
              > CJ Web Work - Solutions for Real Estate Investors.
              > 972 216-4952
              >
              > CJ Web Hosting - Affordable Hosting - Custom Accounts.
              > 254 968-8328
            Your message has been successfully submitted and would be delivered to recipients shortly.