I have files full of customer data with phone # info in an area where many new area codes have been added. Many, although not all, of the recods contain no area code from the days when the city had one, not four area codes. When I parse a record with a 7 instead of 10 digit number, I need to compare it to a list of exchage prefixes for the area to determin the correct area code. I could do 1 IF statement for each of the nearly 800 prefixes which I know; but, there must be a more elegant way to compare each prefix to an external file with regular expressions.
The start of my basic code structure is:
Any suggestions would be appreciated.
-Allen
The start of my basic code structure is:
Code:
NR>1{
gsub ("-","");
gsub ("\"","");
n=n+1;
if(length($7)==10)
{ # split phone no w area_code
area_code = substr($7,1,3);
phone = substr($7,4,7);
}
else
{
# compare and fix missing area_codes here }
print n,$1,$2,Z,area_code,phone;
}
-Allen