Você está marcado como awk
, esperamos que o Python seja útil.
Código:
# !/usr/bin/python
import operator
import sys
with open(sys.argv[1], 'rU') as f:
header = next(f).split()
for line in f:
data = line.split()
numbers = [float(i) for i in data[1:]]
max_index, max_value = max(
enumerate(numbers), key=operator.itemgetter(1))
del numbers[max_index]
half = len(numbers) >> 1
numbers.sort()
if len(numbers) % 2:
median = numbers[half]
else:
median = sum(numbers[half-1:half+1]) / 2.0
if max_value > median * 2:
print('{}\t{}\t{}'.format(
data[0], header[max_index+1], max_value))
Resultados:
g1 s1 20.17
g2 s3 94.0
g5 s2 0.19
g7 s1 2.28