-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexcelDbExample.awk
More file actions
51 lines (41 loc) · 1.08 KB
/
Copy pathexcelDbExample.awk
File metadata and controls
51 lines (41 loc) · 1.08 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
# Creates a Pivot Table:
BEGIN {
# These can also be specified on the command line.
IT = "excel:sheet=real_estate";
FS = "[\t]";
loadArray(querySql, "customer_sql.xml");
querySql["sqlQuery"] = querySql["sqlQueryRow"];
# Use sorted array.
createSortedArray(zips);
}
# Skip headers
(FNR == 1) {
next;
}
# Check for empty line
($0 == "null") {
next;
}
# else
{
zips[$3]++;
}
END {
# Tell compiler that this is an array.
customer[0];
# Use sorted array.
createSortedArray(customer);
# Find database entries with zip codes that are in the excel file.
for (zip in zips) {
zip = integer(zip);
querySql[":zip"] = zip;
statementHandle = queryDatabase(querySql, outArrays);
for (i in outArrays) {
copyArray(customer, outArrays[i]);
print customer;
}
}
if (statementHandle != "") {
closeDatabaseStatement(statementHandle);
}
}