I have a csv which has lot of columns . I was looking for an awk script which would extract a column twice. for the first occurance the header and data needs to be intact but for the second occurance i want to replace the header name since it a duplicate and extract year value which is in ddmmyy and replace it with yyyy.
my csv looks like
"abc","sdf","sdf","we","qe","fr","ty","hgf","er","jy","PERIOD_END_DATE"
"123","","234","ety","","ghj","tyu","Inh","dn","ngnh","17-FEB-19"
what i want to do is use an awk script to print the 11th column twice and extract the year from the data and print it in yyyy format as below:
"PERIOD_END_DATE" "YEAR"
"17-FEB-19" "2019"
Currently i can extract the following from my csv:
"PERIOD_END_DATE" "PERIOD_END_DATE"
"17-FEB-19" "17-FEB-19"
using the awk script as follows:
awk -F ',' '{print $11,$11"\r"}' test1.csv > test2.csv
But what i need is the second column header to be replaced to "Year" and extract the year from the columns and print it in yyyy format for the whole column, so it will look like :
"PERIOD_END_DATE" "YEAR"
"17-FEB-19" "2019"
Can anyone help me with this, Please ask for more clarity if this is unclear.