I have this file.csv
"201707"|"51976551"|1|0|1|"20170702"
"201707"|"51955194"|1|0|0|"20170702"
"201707"|"51923555"|1|0|1|"20170702"
"201707"|"51976551"|1|0|1|"20170703"
"201707"|"51955194"|1|0|0|"20170703"
"201707"|"51923555"|1|0|1|"20170703"
"201707"|"51960597"|1|0|0|"20170703"
And my hope result is group by the number and sum the column 3, 4 and 5
"201707"|"51976551"|2|0|2
"201707"|"51955194"|2|0|0
"201707"|"51923555"|2|0|2
"201707"|"51960597"|1|0|0
I've tried with:
cat file.csv | awk -F"|" '
{ a[$2] += $3 }
END {
for (i in a) {
printf "%s|%s\n", i, a[i];
}
}
'
And the result is:
"51976551"|2
"51955194"|2
"51923555"|2
"51960597"|1
Only shows the sum of third column, but I need 2 columns more. what should I do in this case?