I have a CSV file which has the following format:
Date,Towns,Count1,Count2 6/26/2015,HYDERABAD,234552,0 ,KARIM NAGAR,7520,0 ,RAJAMUNDRY,7248,256 ,KURNOOL,5848,32,0 ,TIRUPATI,8560,64,0 ,VIJAYAWADA,16776,96,0,0,16872 ,VIZAG,30264,624,8,0.0128205128205128,30888 ,WARANGAL,14112,880,0,0,14992 ,GUNTUR,10304,224,0,0,10528 6/27/2015,HYDERABAD,0,6960,0,0,6960 ,KARIM NAGAR,0,0,0,ERROR,0 ,RAJAMUNDRY,0,256,0,0,256 ,KURNOOL,0,32,0,0,32 ,TIRUPATI,0,64,0,0,64 ,VIJAYAWADA,0,96,0,0,96 ,VIZAG,0,528,0,0,528 ,WARANGAL,0,880,0,0,880 ,GUNTUR,0,224,0,0,224
This CSV has number of columns and rows. The rows are grouped based on dates in such a way that each Town has its separate counters and the CSV has the row values for each town which are separated by the first column (date).
Is there a way to read this CSV file using a shell script in such a way that the code identifies the start and end of each day (which can be based on either the date column or the town column) and groups the rows according to that? Say, i want the find the total of Count2 from 6/26/2015 (which will be the sum of all the towns from HYDERABAD to GUNTUR on 6/26/2015)?