Hi guys, I'm new at awk and I'm learning but I'm really lost at the below.
I have the following dataset:
"DAY_OF_MONTH","DAY_OF_WEEK","ORIGIN","DEST","DEP_TIME","DEP_DEL15","CANCELLED","DIVERTED","DISTANCE"
1,Tuesday,ORD,GRB,1003,0.00,0.00,0.00,279.966
1,Tuesday,TUL,ORD,1027,0.00,0.00,0.00,941.265
7,Monday,AUS,MSY,0838,0.00,0.00,0.00,714.396
17,Thursday,AUS,SFO,0.00,0.00,0.00,2419.94
It continues with more registers.
Description of the attributes
- DAY_OF_MONTH: Day of the month
- DAY_OF_WEEK: Name of the day of week
- ORIGIN: Departure airport
- DEST: Destination airport
- DEP_TIME: Departure time in hhmm format
- DEP_DEL15: flight delay (1 there's delay, 0= no delay)
- CANCELLED: cancelled flight (1 cancelled, 0= not cancelled)
- DIVERTED: diverted flight (1 diversion 0= no diversion)
- DISTANCE: distance between airports in km.
Problem
I need to compute the delays per day. I want to create a script that given the dataset, for each day of the week, it computes the percentage(%) of flights with delay, the total number of flights with delay and the total of flights.
Expected Output
Weekday, %delayed, delayed, total_flights
Tuesday,9.8751,9559,96799
Moday,9.86118,7558,76644
Friday,19.0201,12462,65520
Sunday,13.5649,11176,82389
Thursday,15.2873,15870,103812
Saturday,14.4269,11326,78506
Wednesday,13.439,13933,103676
Because I'm new at awk I'm having some problems to perform group by operations and I don't really know how to do it. Furthermore, I see the need of storing variables that will be used afterwards to perform more computations. For example, %delayed will be
computed like (delayed/total_flights)*100
Thank you very much!