rendered paste body#!/usr/bin/perl
open(FILE2, "text3.txt");
open(OUT,">output.txt");
while (<FILE2>){
#print "processing $_";
chomp;
if($_ =~ /^=/){
next;
}
if($_ =~ /^\s*$/){
next;
}
if($_ =~ /PAGE [0-9]+/){
next;
}
if($_ =~ /CODE/){
next;
}
if($_ =~ /D I A G N O S I S/){
next;
}
$code = substr($_,0,5);
$description = substr($_,7,63);
if($code =~ /^\s*$/){
next;
}
if($description =~ /^\s*$/){
next;
}
($prefix,$suffix) = split(/\./,$code);
if(defined($codes{$code})){
$sqlCode = $code;
for($i=0;$i<$codes{$code};$i++){
$sqlCode = "$sqlCode$suffix";
}
}else{
$sqlCode = $code;
}
$sql = <<END;
INSERT INTO MWDIA VALUES('$sqlCode', NULL, NULL, '$description', NULL, NULL, NULL, NULL, NULL, NULL )
END
print OUT "$sql\n";
print "$sql";
$codes{$code}++;
}
close(FILE2);
close(OUT);