I have a raw data file:
70,1,1,-53.25
70,1,1,,,,-57.50
70,1,1,,,,,,,,,,-48.00
I want to have a output file with the formatting below:
70,1,1,-53.25,,,,-57.50,,,,,-48.00
I mean if these rows have the first similar three variables which will be group into one row. And I try to write a awk script:
BEGIN { FS=",";}
{
for(i = 1; i <= NF; i++)
if ( i == NF ) {
arr[$i] = $NF
}
}
END{
for(i = 1; i <= 27; i++)
{
if (i in arr) { printf arr [i]; printf "," ; }
else printf "," ;
}
}
but the result is not expected. I think the problem because the array "arr" cannot receive the any value. Which problem ?