Solved

extract keyword

Posted on 2004-09-24
10
275 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
  • 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
 

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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now