Hi everybody,
I need some help please
I have a csv file named masterFile1.csv
header1,header2,header3
value1,value2,value3
value4,value5,value6
I am trying to add new columns in the end of the csv to have a new csv file named masterFile2.csv like this :
header1,header2,header3,period,region
value1,value2,value3,20110328,/home/kamel1985/Desktop
value4,value5,value6,20110328,/home/kamel1985/Desktop
the period columns will give the date of today 20110328 28th March 2011 and the region columns will give the path of the csv file.
I have tried something like this to add the columns but it allows to add the colums before not int the end of the csv file
awk -vc1="period" -vc2="region" -vd1=$(date '+%Y%m%d') -vd2=$(pwd) 'NR==1{$0=c1","$0}NR==1{$0=c2","$0}NR!=1{$1=d1","$1}NR!=1{$1=d2","$1}NF' masterFile1.csv> masterFile2.csv
and it gives somthing like this
region,period,header1,header2,header3
/home/kamel1985/Desktop,20110328,value1,value2,value3
/home/kamel1985/Desktop,20110328,value4,value5,value6
How can I modify the previous command to add the columns in the end of the csv file to have
header1,header2,header3,period,region
value1,value2,value3,20110328,/home/kamel1985/Desktop
value4,value5,value6,20110328,/home/kamel1985/Desktop
Thank you very much in advance !