-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQuestion2-ProblemSet2
More file actions
66 lines (44 loc) · 2.47 KB
/
Copy pathQuestion2-ProblemSet2
File metadata and controls
66 lines (44 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#2. Produces a table (text is fine) with the data to fill in this table (*13 points*):
GNV to: | Total flights | Total flights delayed (>15min) | Total flights delayed due to Weather
--------|---------------|--------------------------------|--------------------------------------
ATL | 1476 | 322 | 15
CLT | 476 | 135 | 3
MIA | 205 | 42 | 0
############################# 2.1 GNV to ATL: ###########################################################
tr ',' '\t' < flights.May2017-Apr2018.csv | sed 1d > flightsTotal
# sed 1d to remove the header
awk '$3 == "\"GNV\"" && $7 == "\"ATL\"" {print $0}' flightsTotal > FlightsGNVtoATL
# To find in column "Origin" ($3) "GNV" and (&&) in column "DEST" ($7) "ATL"
# Total flights
wc -l FlightsGNVtoATL
1476 FlightsGNVtoATL
# Total flights delayed (>15min)
awk '$13 == 1.00 || $16 == 1.00 {print $0}' FlightsGNVtoATL | wc -l
# Output: 322
# Departure Delay ($13) or (||) Arrival Delay ($16), then print all columns ($0)
# Total flights delayed due to Weather
awk '$13 == 1.00 || $16 == 1.00 ' FlightsGNVtoATL| awk '$24 > 0.00' |awk '{print $0}'|wc -l
# Output: 15
# Departure Delay ($13) or (||) Arrival Delay ($16), and the delayed is due to Weather ($24), then print all columns ($0)
############################# 2.2 GNV to CLT: ###########################################################
tr ',' '\t' < flights.May2017-Apr2018.csv | sed 1d | awk '$3 == "\"GNV\"" && $7 == "\"CLT\"" {print $0}' > FlightsGNVtoCLT
# Total flights
wc -l FlightsGNVtoCLT
# Output: 476 FlightsGNVtoCLT
# Total flights delayed (>15min)
awk '$13 == 1.00 || $16 == 1.00 {print $0}' FlightsGNVtoCLT | wc -l
# Output: 135
# Total flights delayed due to Weather
awk '$13 == 1.00 || $16 == 1.00 ' FlightsGNVtoCLT| awk '$24 > 0.00' |awk '{print $0}'|wc -l
#Output: 3
############################## 2.3 GNV to MIA: ###########################################################
tr ',' '\t' < flights.May2017-Apr2018.csv | sed 1d | awk '$3 == "\"GNV\"" && $7 == "\"MIA\"" {print $0}' > FlightsGNVtoMIA
# Total flights
wc -l FlightsGNVtoMIA
#Output: 205 FlightsGNVtoMIA
# Total flights delayed (>15min)
awk '$13 == 1.00 || $16 == 1.00 {print $0}' FlightsGNVtoMIA |wc -l
#Output: 42
# Total flights delayed due to Weather
awk '$13 == 1.00 || $16 == 1.00 ' FlightsGNVtoMIA| awk '$24 > 0.00' |awk '{print $0}'|wc -l
#Output: 0