blob: e5e8fea24002b750c1f30d0a1022ee0b9effbf0c (
plain) (
blame)
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
|
### diff.awk
# numerical diff along columns
BEGIN {
sign = "[+-]?"
decimal = "[0-9]+[.]?[0-9]*"
fraction = "[.][0-9]*"
exponent = "([Ee]" sign "[0-9]+)?"
number = "^" sign "(" decimal "|" fraction ")" exponent "$"
}
NR == 1 {
header_nf = NF
for (n=1; n<=NF; n++) {
if ($n !~ number)
header[n] = "d" $n
else
header[n] = "col_" n
printf("%s,", header[n])
}
}
NF != 0 {
if (NF > max_nf)
max_nf = NF
### iterate over columns
for (y=1; y<=max_nf; y++) {
if ($y ~ number) {
data[y] = $y
diff[y] = data[y] - data_prev[y]
printf("%g,", diff[y])
data_prev[y] = data[y]
}
}
printf("\n")
}
|