I use the following script to re-format data by separating the area code from the phone number in the file, and providing a default area-code if there isn't one in the original record. The only problem is, that upon output, I get two lines per record, instead of one. Any help would be appreciated, here is my code:
Thanks in advance for any ideas...
-Allen
Code:
BEGIN {
FS=",";
OFS=",";
print "CustomerID,FirstName,LastName,TimeZone,AreaCode,PhoneNumber";
Z="MST"; #time zone
}
NR>1{
gsub ("-","");
gsub ("\"","");
if(length($5)==10)
{ # split phone no w area_code
area_code = substr($5,1,3);
phone = substr($5,4,7);
}
else
{
phone=$5;
area_code = 623;
}
print $1,$3,$4,Z,area_code,phone;
}
Thanks in advance for any ideas...
-Allen