I have a file with the format
CKF,23G
ckf,234M
CKF,2356K
DFK,4589M
DFK,343K
dfk,3434M
DFK,34G
DFK,34343M,
DFK,3476G
FGK,34k
KLK,43G
KLK,3G
I would like to group by the 3-letter code in the beginning of the file and sum up the second column in giga bytes and output a file like the following :
CKF,<sum_total_of_all_rows_in_gigabytes>G
DFK,<sum_total_of_all_rows_in_gigabytes>G
FGK,<sum_total_of_all_rows_in_gigabytes>G
KLK,<sum_total_of_all_rows_in_gigabytes>G
To calculate in giga bytes, the size mentioned on each row needs to be handled as follows :
if suffix is G, then do nothing, simply add to running_total
if suffix is M or m, then divide by 1024 and add to running_total
if suffix is K o k then divide by (1024*1024) and add to running_total