awk-hack-the-planet icon indicating copy to clipboard operation
awk-hack-the-planet copied to clipboard

Recreate payroll file

Open ahmartello opened this issue 3 years ago • 0 comments

Description

There is two problematic rows in the previous file. Rerunnig the script and recreating the payroll.tsv file solves the issue.

Issue found

Trying to solve the question 10 (how many engineers the company has), i came up with this:

awk 'BEGIN {cont=0} /Engineer/ {cont++} END {print cont}' payroll.tsv

which return 2213 records. But, running the code from 10.akw, the answer came up as 2211. The difference is because the code in 10.awk only match as $6 ~ /Engineer/ while i'm matching anywhere in the row.

The rows that led to the difference can be found with:

awk '$0 ~ /Engineer/ && $6 !~/Engineer/ {print}' payroll.tsv
HymanHarriman	10.36	40	NewYork	MechanicalEngineer	2014/01/12
Byron Oba	Dipasquale	14.65	28	Seattle	MechanicalEngineer	1995/05/01

The first without Lastname column and the second with three columns for names.

Alternatives

if you want to keep the solutions closer to what was shown in the video tutorial (which brought me here), i can change these lines manually in the payroll.tsv file (as done in #2 ). But, as the script works fine, recreating the data solves the issue.

ahmartello avatar Sep 12 '22 17:09 ahmartello