我的数据如下:
awk ' ##Starting awk program here.
BEGIN{ ##Starting BEGIN section from here.
FS=OFS="," ##Setting FS and OFS as comma here.
} ##Closing BLOCK for BEGIN section here.
!b[$3]++{ ##Checking condition if $3 is NOT present in array b then do following + it is placing $3 in array b.
c[++count]=$3 ##Creating an array named c whose index is variable count and value is $3, variable count value is keep increasing with 1.
} ##Closing BLOCK for array b condition here.
{
a[$3]+=$4 ##Creating an array named a with index $3 and value is $4 and its keep adding its value to its own same index value.
}
END{ ##Starting END section of this program here.
for(i=1;i<=count;i++){ ##Starting for loop from i=1 to till value of count variable here.
print c[i],a[c[i]] ##Printing array c value index variable i and printing array a value whose index is array c with index variable i.
} ##Closing BLOCK for, for loop here.
} ##Closing BLOCK for END section of this program here.
' Input_file ##Mentioning Input_file name here.
我想转换为:
Name Question Points
a q1 2
a q2 4
a q3 1
b q1 5
b q2 3
在大熊猫中有一种简单的方法吗?