from MatrixIO import *
from sys import *
from Shane import *

argv = argv[1:]
if len(argv) == 0:
    print "usage: meanData <input.data...> <output.data>"
    exit(2)
inputNames = argv[0:len(argv) - 1]
outputName = argv[-1]
print inputNames
print outputName

input = []
for name in inputNames:
    input.append(readMatrix(name))

# Assume they all have the same row size.

m = sumv(input)/float(len(input))
out = open(outputName, 'w')
writeMatrix(m, out)    
out.close()
    

# I've got all the matrices
# What's the minimum row size?
#rowSizes = map(lambda m: m.shape[0], input)
#rowSize = minimum(rowSizes)
