Hi,
first, I have searched in the forum for this, but I could not find the right answer. (There were some similar threads, but I was not sure how to adapt the ideas.)
Anyway, I have a quite natural problem: Given are several text files. All files contain the same number of lines and the same number of columns. I want to compute a file that contains at each cell (interpreting the files as tables) the average value of the corresponding cells from my files.
There is a problematic thing in the files: The cells may contain numbers or the string "n/a" which means something like "not computed". When some files have a "n/a" at some cell, then the result file should contain the average from the not-"n/a" values and (separated by some unique symbol like "~") the number of "n/a" values.
For example:
File 1
1 2 3
1 n/a 3
File 2
3 2 1
3 n/a 1
File 3
2 2 n/a
5 2 5
Now, want to compute the following:
Resultfile
2 2 2~1
3 2~2 3
Of course, I could implement this with some high-level programming language, but having this as script would make it much more comfortable in my application.
I think this should be easy for experts of awk or similar tools. Unfortunately I don't see an easy solution.
Thanks in advance.