Solved

extract keyword

Posted on 2004-09-24
10
282 Views
Last Modified: 2010-03-05
hi this is my text file sample.
I'm able to extract all the keywords that i want , except for "coplanarity"
I want to be able to extract the coplanarity's "defect" column's value.
Can someone pls help me?
thankS


GQ5.3C.04                       YIELD REPORT          : mils
Job     : PQFP64-ASAT-14x14-LIS    Start Date: 07/29/04
Tray    : ABC          Start Time: 12:21:13
Package : ABC          Sensor Ht.: 239.17 mils
Operator: TAN          Run Time  : 23:28:21
Mach S/N: LKJ          Lot       : 123
__________________________________________________________________________
NUMBER OF DEVICES INSPECTED : 23
NUMBER OF DEVICES ACCEPTED  : 23         YIELD : 100.00%
NUMBER OF DEVICES REJECTED  : 0
__________________________________________________________________________
CAUSE FOR REJECTION           INSPECTION LIMITS   DEFECT   REWORK
COPLANARITY                    0.02  to    1.36      0        0
TRUE POS SPREAD               -5.98  to    5.98      0        0
MARK INSPECTION OFF              NA                  0        0
FAILED TO SEGMENT                NA                           0
MISSING DEVICE                   NA                          23


This is the Perl codes.

#!/usr/bin/perl
    use strict;
    use warnings;

    use DBI;
    use Date::Manip;
    use File::Spec::Functions qw(curdir rel2abs);
    use File::Find;

    my( $dbh, $sth, $query );

    $dbh = DBI->connect( 'dbi:mysql:rvsi', '', '', {RaiseError=>1, PrintError=>1} );
    $query = 'replace into yield2 ( job, date, lot, report, dir, qin, qout, yield, reject ) values ( ?,?,?,?,?,?,?,?,?)';
    $sth = $dbh->prepare( $query );

    find(
    sub{
        return unless -f;
       
        print "Processing $_\n";

        @ARGV = ($_);
        my ($report, $job, $lot, $date, $fname, $qin, $qout, $yield, $reject);

        {
            local $_ = join '', <>;
            tr/\xA0//;  ## I had to do this for one of your sample records, or it wouldn't match

            ($report) = /(Yield Report)/i;
            ($job)= /Job\s*:\s*(\S+)\s*/i;
            ($date) = /Start Date\s*:\s*(\S+)\s*/i;
            ($lot) = /Lot\s*:\s*(.*)/i;
            ($qin) = /NUMBER OF DEVICES INSPECTED\s*:\s*(.*)/i;
            ($qout) = /NUMBER OF DEVICES ACCEPTED\s*:\s*(\S+)\s*/i;
            ($yield) = /YIELD\s*:\s*(.*)/i;
            ($reject) = /NUMBER OF DEVICES REJECTED\s*:\s*(.*)/i;


            $fname = rel2abs( $ARGV);

            print "I found the following values:\n";
            print "\tReport: >$report<\n";
            print "\tJob: >$job<\n";
            print "\tDate: >$date<\n\n";
            print "\tLot: >$lot<\n";
            print "\tNumber of Devices Inspected: >$qin<\n";
            print "\tNumber of Devices Accepted: >$qout<\n";
            print "\tYield: >$yield<\n";
            print "\tNumber of Devices Rejected: >$reject<\n";

            # check if there is any values in job, it will insert the whole line of entRies in
            if($job){
                # We have a full record            
               

                print "Inserting record... ";
                $sth->execute($job, $date, $lot, $report, $fname, $qin, $qout, $yield, $reject);
                print "done.\n\n";
            }
        }
    },".");


0
Comment
Question by:TPoly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 12140995
($defect) = /COPLANARITY\b.+(\d+)\D+\d+/i;
0
 

Author Comment

by:TPoly
ID: 12156814
hi
i tried
it did extract the info out
but it does not match with the corresponding text file
(meaning wrong or no info)
0
 
LVL 84

Expert Comment

by:ozo
ID: 12156836
Could you show a sample for which it gives the wrong info and what the info should have been?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:TPoly
ID: 12157178
the value of the coplanarity is 9 but output catched is 5.
0
 
LVL 84

Expert Comment

by:ozo
ID: 12157201
What did the input line look like to specify that the value should be 9?
0
 

Author Comment

by:TPoly
ID: 12157420
CAUSE FOR REJECTION           INSPECTION LIMITS   DEFECT   REWORK
COPLANARITY                    0.02  to    1.36      9        0

I want to extract coplanarity's defect value.
The value is 9
but when i check against the db, the value is different, in this case is 5
0
 
LVL 84

Expert Comment

by:ozo
ID: 12157452
Does the word "coplanarity" appear anywhere else in the input?
0
 

Author Comment

by:TPoly
ID: 12158092
yes it does

It looked like this:



GQ5.3C.04                       YIELD REPORT          : microns
Job     : abc                    Start Date: 08/11/04    
Tray    : 123                    Start Time: 09:57:05    
Package : Sin                    Sensor Ht.: 167.72 mils
Operator: JAMES                  Run Time  : 09:57:05    
Mach S/N: plk                    Lot       : goO          
__________________________________________________________________________
NUMBER OF DEVICES INSPECTED : 1
NUMBER OF DEVICES ACCEPTED  : 1           YIELD : 100.00%
NUMBER OF DEVICES REJECTED  : 0
__________________________________________________________________________
CAUSE FOR REJECTION           INSPECTION LIMITS   DEFECT   REWORK
COPLANARITY                    0.00  to   25.01      0        0
TRUE POS SPREAD              -69.23  to   69.23      0        0
MARK INSPECTION OFF              NA                  0        0
FAILED TO SEGMENT                NA                           0
MISSING DEVICE                   NA                           0

FAILED TO SEGMENT    Side 1: 0, Side 2: 0, Side 3: 0, Side 4: 0



____________________________________________________________________________________________________________________

CAPABILITY ANALYSIS       LSL   NOMINAL       USL       MIN      MEAN       MAX     SIGMA    3SIGMA      Cp     Cpk
____________________________________________________________________________________________________________________
COPLANARITY               0.0       0.0      2.0      35.6      48.4      48.5       0.0       0.0     0.0     0.0
TRUE POS. SPREAD        -36.0       0.0      4.0     -169.0     0.9       69.0       4.8      14.5     5.1     5.1
0
 
LVL 84

Accepted Solution

by:
ozo earned 125 total points
ID: 12167730
That looks like $defect should be 0, why do you say it should be 9?
To get the 0 and not the 0.0 you could use

($defect) = /COPLANARITY\s+\S+\s+\S+\s+\S+\s+(\d+)\D+\d+\s*$/i;
0
 

Author Comment

by:TPoly
ID: 12176296
thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Rename file based on contents in the file? 3 106
use google analytics code in perl script 2 99
To run CGI/perl on tomcat and connect to oracle database. 5 156
Perl Untar File 1 76
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question