Below is my input and output .txt
files.
I want to group by the data by StatusDate
and Method
. And then sum the values based on the StatusDate
and Method
.
Input.txt
No,Date,MethodStatus,Key,StatusDate,Hit,CallType,Method,LastMethodType 112,12/15/16,Suceess,Geo,12/15/16,1,Static,GET,12/15/16 113,12/18/16,Suceess,Geo,12/18/16,1,Static,GET,12/18/16 114,12/19/16,AUTHORIZED,Geo,12/19/16,1,Static,GET,12/19/16 115,12/19/16,AUTHORIZED,Geo,12/19/16,1,Static,GET,12/19/16 116,12/19/16,Suceess,Geo,12/19/16,1,Static,PUT,12/19/16 117,12/19/16,Suceess,Geo,12/19/16,1,Static,PUT,12/19/16 118,12/19/16,Waiting,Geo,12/19/16,1,Static,GET,12/19/16 119,12/19/16,AUTHORIZED,Geo,12/19/16,1,Static,GET,12/19/16 120,12/17/16,Suceess,Geo,12/17/16,1,Static,GET,12/17/16 121,12/17/16,Suceess,Geo,12/17/16,1,Static,GET,12/17/16 130,12/16/16,Suceess,Geo,12/16/16,1,Static,GET,12/16/16
Out.txt
StatusDate,12/15/16,12/16/16,12/17/16,12/17/16,12/18/16,12/19/16,12/19/16,12/19/16,12/19/16,12/19/16,12/19/16,Grand Total GET,1,1,1,1,1,1,1,1,1,,,9 PUT,,,,,,,,,,1,1,2 Grand Total,1,1,1,1,1,1,1,1,1,1,1,11
I'm using awk
and splitting the data by awk -F, '{if($8=="GET") print }'
, then calculating the sum value. Since the file size is huge, there is a delay.
Is it possible to do everything in one step? So the file operation will be reduced?