Maximum List size (item number) limit?
bearophileHUGS at lycos.com
bearophileHUGS at lycos.com
Wed Jan 11 08:13:40 EST 2006
Juho Schultz
>NIR_mean_l only from lines 1, 4, 7, ...
>R_mean_l only from lines 2, 5, 8, ...
>G_mean_l only from lines 3, 6, 9, ...
This can be the problem, but it can be right too.
The following code is shorter and I hope cleaner, with it maybe
Kriston-Vizi Janos can fix his problem.
class ReadData:
def __init__(self, filename):
self.NIR_mean = []
self.NIR_stdev = []
self.R_mean = []
self.R_stdev = []
self.G_mean = []
self.G_stdev = []
self.area = []
for line in file(filename):
row = line.split()
self.area.append(row[1])
self.NIR_mean.append(row[2])
self.NIR_stdev.append(row[3])
self.R_mean.append(row[4])
self.R_stdev.append(row[5])
self.G_mean.append(row[6])
self.G_stdev.append(row[7])
# -------------------------------
L = ReadData('L.txt')
GC = ReadData('GC.txt')
out_file = file('merged.txt', 'w')
# Create output rows from lists
for i in xrange(len(L.NIR_mean)): # Process all input rows
# Filter L and GC rows by area values
if (10000 <= float(L.area[i]) <= 100000) and \
(10000 <= float(GC.area[i]) <= 100000):
# Create output line and write out
newline = [str(i+1)]
for obj in L, GC:
newline.extend([obj.NIR_mean[i], obj.NIR_stdev[i],
obj.R_mean[i], obj.R_stdev[i],
obj.G_mean[i], obj.G_stdev[i],
obj.area[i]])
outline = '\t'.join(newline) + '\n'
out_file.write(outline)
out_file.close()
More information about the Python-list
mailing list