-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexcelExample.awk
More file actions
63 lines (50 loc) · 1.35 KB
/
Copy pathexcelExample.awk
File metadata and controls
63 lines (50 loc) · 1.35 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
# Creates a Pivot Table.
BEGIN {
# These can also be specified on the command line.
IT = "excel:sheet=real_estate";
FS = "[\t]";
# Use sorted arrays
createSortedArray(zipBeds);
createSortedArray(zipBaths);
createSortedArray(totalBeds);
createSortedArray(totalBaths);
}
# Skip headers
(FNR == 1) {
next;
}
# Check for empty line
($0 == "null") {
next;
}
# else
{
zip = $3;
beds = $5;
baths = $6;
zipBeds[zip, beds]++;
zipBaths[zip, baths]++;
totalBeds[beds]++;
totalBaths[baths]++;
}
END {
print "Processed", FNR, "row(s)";
for (i in zipBeds) {
split(i, a, SUBSEP);
print "Number of places with", a[2], "bedroom(s) for zip code", a[1], "is", zipBeds[i];
}
print "";
for (i in zipBaths) {
split(i, a, SUBSEP);
print "Number of places with", a[2], "bath(s) for zip code", a[1], "is", zipBaths[i];
}
print "";
for (i in totalBeds) {
print "Total number of places with", i, "bedroom(s) is", totalBeds[i];
}
print "";
for (i in totalBaths) {
print "Total number of places with", i, "bath(s) is", totalBaths[i];
}
print "";
}