Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I really need help with this question! It has to deal with awk scripting and pro

ID: 3828180 • Letter: I

Question

I really need help with this question! It has to deal with awk scripting and programming. Please help me!

Consider the data below, stored in a file called rawaddresses. It was made up by the students. But it is the type of raw data that IT professionals are often asked to process.

The data consists of, in order: full name, 9-digit student ID, email address, 10-digit phone number, 2- uppercase letters state code, optional street number, optional direction, street name, city, and 5-digit zip code.

The full name consists of first name that starts with uppercase character, either a middle initial (in uppercase, no dot after) or a middle name (starts with an uppercase letter) or no middle, and a last name (starts with an uppercase letter).

The street direction, when provided, is an uppercase letter.

The street names and city names all start with uppercase letter. It can be assumed that city names are all a single word; but street names could have multiple words, each starting with uppercase letters or a digit (eg. 5th St).

Write an awk program/script, called lab6.awk, to process the above data and present in the format below (store the output in a file called addressbook):

Ryan Wehe, 989-98-7412

2001 Blake St

Denver, CO 80205

wehe@asu.edu    

(202) 555-0126    

Joseph Lee, 605-49-7184

5986 Budweiser Way

Alamosa, CO 81101

josephl@mailinator.com

(303) 555-0103

AmyJohnson, 783-33-3251

14 N 5th St

Minneapolis, MN 55403

amyj@mailinator.com

(651) 555-0164

I geniunely need help as I don't have a lot of time to complete this assignment. Honest and GENUINE help would be deeply appreciated. Please provide a detailed and complete answer for this question. PLEASE use awk scripting and programming ONLY! Do NOT answer in Java/programming language code, or give a few paragraphs on how to use a UNIX command, or even UNIX bash or perl script. I need 100% complete and genuine help and a definite solution to my problem. I am in deep need of help. PLEASE do not let me down.

Insert vraw Lesign Layout Reterences Mailings Review View Tell me what you want to do File Home AaB Aria AaBb AaBb. AaBbc Aatboel AaB,C Paste mphasis 1 Heading 1 Heading 21 Heading 3 1 Norm Subtitle No Spac. Subtle Em Format Painte assumea tnat City names are all a single Wora, put street names Coula nave multiple words, each starting with uppercase letters or a digit (eg. 5th St) Wehe989987412rwehe@asu.edu2025550126CO2001BlakestDenver80205 Ryan Joseph Lee605497184josephl@mailinator.com3035550103CO5986BudweiserWayAlamosa81101 Amy Johnson 783333251amyja thStMinneapolis55403 Daniel JEverhard314849866everhard@asu.edu5059358554NM8830JohnsonRdAlbuquerque87122 PhilipEPeterson325764011peterson@asu.edu4561238888WA542468thAveLacey98513 Matt Nulk 1240857 33nulk@asu.edu2093865442KSManhattanStRiley87512 Brandon TLyons123456123btlyons1@asu.edu5755595459AZ635WElmStMesa85212 RogerATurtle983421567rat@gmail.com8587754321IA3400sWIslanDrdDesmoines50021 Marc JWhiz 745629754 marcwhiz 76@yahoo.com6195323200CA215NCollegeGroveWaysandiego91210 Write an awk program, called lab6.awk, to process the above data and present in the format below (store the output in a file called addressbook): Page 2 of 4 a Ask me any Share Replace 4/20/2011

Explanation / Answer

code:
#!/usr/bin/awk -f
# script name: lab6.awk
{
   # getting student id
   match($0,/[0-9]{9}/);
   sid = substr($0, RSTART, RLENGTH);
   # getting phone number
   match($0,/[0-9]{10}/);
   phone = substr($0, RSTART, RLENGTH);
   # getting zip code
   match($0, /[0-9]{5}$/);
   zip = substr($0, RSTART, RLENGTH);
   # getting name
   match($0,/[a-zA-Z]*[0-9]{9}/);
   name = substr($0, RSTART, RLENGTH);
   split($0,a,"[0-9]*");
   name = a[1];
   # getting email id
   match($0,/[a-zA-Z]*@[a-zA-Z.]*/);
   email = substr($0, RSTART, RLENGTH);
   # getting state code
   match($0,/[A-Z][A-Z]/);
   state_code = substr($0, RSTART, RLENGTH);
   # getting street
   match($0,/[A-Z][A-Z][0-9a-zA-Z]*[0-9]{5}$/);
   street = substr($0, RSTART, RLENGTH);
   str_len =length(street);
   street1 = substr(street, 3, str_len-7);
   # getting city
   match(street1, /[A-Z][a-z]*$/);
   city=substr(street1, RSTART, RLENGTH);
   # printing formmatted output
   print name "," substr(sid,1,3) "-" substr(sid,4,2) "-" substr(sid,7,4);
   sub(city,"",street1);
   print street1;
   print city "," state_code " " zip;
   print email;
   print "(" substr(phone,1,3) ") " substr(phone,4,3) "-" substr(phone,7,4);
   print " ";
}


Input file:
186590cb0725:Chegg bonkv$ cat rawaddresses
RyanWehe989987412rwehe@asu.edu2025550126CO2001BlakeStDenver80205
JosephLee605497184josephl@mailinator.com3035550103CO5986BudweiserWayAlamosa81101
AmyJohnson783333251amyj@mailinator.com65155550164MN14N5thStMinneapolis55403

output:
186590cb0725:Chegg bonkv$ cat rawaddresses |./lab6.awk
RyanWehe,989-98-412
2001BlakeSt
Denver,CO 80205
rwehe@asu.edu
(202) 555-0126


JosephLee,605-49-184
5986BudweiserWay
Alamosa,CO 81101
josephl@mailinator.com
(303) 555-0103


AmyJohnson,783-33-251
14N5thSt
Minneapolis,MN 55403
amyj@mailinator.com
(651) 555-5016