Hi,
You posted on a
query I had over a data manipulation task. The code you wrote seems well structured and I would like to understand it a little more.
Code:
awk 'BEGIN{OFS=FS=", "
c["N"]="01"
c["C"]="02"
c["L"]="03"
}
NR==1{print}
NR>1{
print $1,$2, c[substr($3,1,1)] substr($3,2) "01"
}
' file
From what I understand so far, the BEGIN OFS skips the first line. I can see that variable (?) "c" is detailing the first two numbers to use. How does this work?
Then NR displays the first line? Then I get stuck on the substr syntax.
If you could explain a little more it would be helpful. I need to amend the script so that in an event that a code's 3 characters (after the first character) are the same as another codes three characters, the 01 at the end will increment by 1.
Example:-
CBUPP = 02BUP01
CBUPI = 02BUP02
CBUPK = 02BUP03
At the moment the script will obviously produce the following:-
02BUP01
02BUP01
02BUP01
Thanks for the help.