Hi,
I am presently stuck in a csv file.
INPUT CSV
baseball,NULL,8798765,Most played
baseball,NULL,8928192,Most played
baseball,NULL,5678945,Most played
cricket,NOTNULL,125782,Usually played
cricket,NOTNULL,678921,Usually played
EXPECTED OUTPUT CSV
baseball,NULL,8798765,Most played
NULL,8928192,Most played
NULL,8928231,Most played
cricket,NOTNULL,125782,Usually played
NOTNULL,678921,Usually played
I am using the below code in input csv
awk -F"," '{if (NR>1 && a==$1) {print FS$2FS$3;a=$1} else {print $0;a=$1}}' input.csv > output.csv
But I am getting the below output:-
baseball,NULL,8798765,Most played
8928192
8928231
cricket,NOTNULL,125782,Usually played
678921
The code is deleting the duplicate items in 2nd column and third columns also...I want that the unique elements of the first column should be displayed but all other things for other columns should remain intact
Can somebody please help me...