[PIPython] creare array multidimensionali

Simone Piunno pioppo
Ven 19 Nov 2004 15:16:45 CET


Pił lo guardo e pił si accorcia....

CRLF = '\r\n'
file_list = 'file_list.txt'
output_file = 'summary.txt'

results = {}
fns = [x.rstrip(CRLF) for x in file(file_list)]
for filename in fns:
    for line in file(filename):
        a, b, c = line.rstrip(CRLF).split('\t')
        results[int(a), int(b), filename] = c.strip()
out = file(output_file, 'w')
m = 1 + max([x[0] for x in results])
for i in range(1, m):
    for j in range(1 + i, 1 + m):
        clist = [results.get((i, j, x), '') for x in fns]
        print >> out, '\t'.join([str(i), str(j)] + clist)

-- 
http://thisurlenablesemailtogetthroughoverzealousspamfilters.org



More information about the Python mailing list