Tag Archives: LOWER

Complex awk problem

By dietmar13

hello,

i have a complex awk problem…

i have two tables, one with a value (0 to 1) and it’s corresponding p-value, like this:

1. table:
______________________________
value p-value
… …
0.254 0.003
0.245 0.005
0.233 0.006
… …
______________________________

and a second with millions of values (0 to 1), like this:
2. table
______________________________

0.252…
0.234…
0.256…

______________________________

now I have to map the second list to the first table so that I get for each value the corresponding p-value (i.e. the p-value corresponding to the LOWER value in the 1. table).

expexted output:
______________________________
… …
0.252… 0.005
0.234… 0.006
9.256… 0.003
… …
______________________________

one possibility would be to create an indexed array with 1000 instances in this way:

a[0.233]=0.006
a[0.234]=0.006

a[0.245]=0.005

then create a substring of the value of the second list like x.xxx and use this as index for the array.

is there an easier way?

thank you,

dietmar

PS: I have to use AWK, because I already read 7 several gbyte large files an combine these in one table (in minutes) and I have to convert one column on the fly to the corresponding p-values. I think every other programming language will be slower (perhaps except C++, which I can’t program).

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums