#!/usr/bin/perl
use strict;
use warnings;
if ($#ARGV != 0) {
print "ARGV = ", $#ARGV, "\n";
print "Usage: FDC46CountLines.pl \n";
exit(1);
}
my $rootPath = $ARGV[0];
my @lotList = ();
my $dataFile = ();
my @dataLine = ();
my @X = ();
my @Y = ();
my @radius = ();
my $tempPath;
my $i;
my $j;
my $panel;
my $lot;
my $lineCount = 0;
my $outputFile = '';
# Generate list of subfolders
opendir DIR, $rootPath or die "Couldn't open dir $rootPath: $!\n";
my @folders = readdir DIR;
closedir DIR;
foreach (@folders) {
if (-d $rootPath . "\\" . $_) {
if ($_ eq ".") {}
elsif($_ eq "..") {}
else {
push(@lotList, $_);
}
}
}
my %lotHash = ();
my $currentLot;
#Generate list of lot folders
foreach (@lotList) {
$tempPath = $rootPath . "\\" . $_;
$currentLot = $_;
opendir DIR, $tempPath or die "Couldn't open dir $tempPath: $!\n";
@folders = readdir DIR;
closedir DIR;
# Generate list of process folders
foreach (@folders) {
if (-d $tempPath . "\\" . $_) {
if ($_ eq ".") {}
elsif($_ eq "..") {}
else {
push(@{$lotHash{$currentLot}}, $_);
}
}
}
}
@folders = ();
for my $key (keys %lotHash) {
for ($i=0; $i <= $#{$lotHash{$key}}; $i++) {
$tempPath = $rootPath . "\\" . $key . "\\" . $lotHash{$key}[$i];
$lot = $key;
$panel = $lotHash{$key}[$i];
print "tempPath = " . $tempPath . "\n";
print "lot = " . $lot . "\n";
print "panel = " . $panel . "\n";
$dataFile = $tempPath . "\\" . $lot . "_" . $panel . "_Notes.txt";
if (open(DATA, "<$dataFile")) {
while () {
@dataLine = split;
push(@X,$dataLine[3]);
push(@Y,$dataLine[4]);
push(@radius, sqrt($dataLine[3]**2+$dataLine[4]**2));
}
} else { print "dataFile does not exist"; }
@radius = sort(@radius);
$outputFile = $tempPath . "\\" . $lot . "_" . $panel . "_defectCount.txt";
open(OUTPUT, ">$outputFile") or die $!;
$lineCount = 0;
for ($j = 1; $j <= $#radius; $j++) {
if (($radius[$j] - $radius[$j-1]) > 100.0) {
print OUTPUT "$X[$j]\t$Y[$j]\n";
$lineCount += 1;
}
}
print OUTPUT "total unique defects were: $lineCount\n";
@dataLine = ();
@X = ();
@Y = ();
@radius = ();
close OUTPUT;
}
}
A blog for my notes on perl and various other programming languages and applications I work on.
Thursday, September 12, 2013
Today's script
Just another throw away script to get things done at work today:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment