Use awk to process some CSV (comma separated values) data in a text file. - Crea
ID: 3799658 • Letter: U
Question
Use awk to process some CSV (comma separated values) data in a text file.
- Create an awk script something.awk to contain your code
- Print with columns
- Hint: add the scores together to get answer from the image below.
Explanation / Answer
Average.awk
# Begin
BEGIN {
FS=" ";
}
# Dev
{
name[NR] = $1;
average[NR] = ($2 + $3 + $4) / 3;
}
# End
END {
i = 1;
while (i <= FNR) {
printf("%-10s %.2f ", name[i] , average[i++]);
}
}
note: execute like
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.