hi all,
i have a file that contains the following data (just a sample) :
501 0 0.932 0.933 0.931 0.931 0.929 0.933 0.93 0.928
501 1 0.974 0.98 0.978 0.976 0.974 0.974
501 2 0.953 0.949 0.944 0.951 0.942 0.942 0.942 0.948
501 3 0.933 0.934 0.934 0.935 0.931 0.933 0.932 0.934
501 4 0.939 0.934 0.934 0.934 0.937 0.932 0.938
501 5 0.944 0.942 0.942 0.943 0.939 0.95 0.942 0.948
501 6 0.974 0.976 0.974 0.971 0.97 0.967 0.971 0.974
501 7 0.986 0.984 0.984 0.986 0.986 0.984
502 0 0.927 0.933 0.931 0.931 0.929 0.933 0.93 0.928
502 1 0.974 0.98 0.978 0.976 0.973 0.971 0.974
502 2 0.953 0.949 0.951 0.942 0.942 0.942 0.948
502 3 0.933 0.934 0.934 0.935 0.931 0.933 0.932 0.931
502 4 0.939 0.934 0.934 0.932 0.937 0.932 0.938
502 5 0.944 0.942 0.942 0.943 0.939 0.95 0.95 0.948
502 6 0.974 0.974 0.974 0.971 0.97 0.967 0.971 0.974
502 7 0.986 0.984 0.984 0.986 0.984 0.986
and i parse it using the following commands :
file_hol = open("<file_name>.dat", "r")
data_hol = []
for line_hol in file_hol :
line_hol = [float(x) for x in line_hol.split()]
data_hol.append(tuple(line_hol))
file_hol.close()
so, i get a list of lists with the name data_hol (everything is ok till now)
the 1st column is a timestamp
the 2nd column is a port number
what i would like to find is the port with the largest sum of the numbers of the rest of the columns
and, eventually, to have a list of ports where a port corresponds to a list of the port number and and the numbers (rest of the columns) with the largest sum,
so
pisa_hol = [0]
for i in range(0, len(data_hol)) :
if sum(data_hol[i][2:len(data_hol[i])]) > sum(pisa_hol[int(data_hol[i][1])][1:len(pisa_hol[int(data_hol[i][1])])]) : pisa_hol[data_hol[i][1]] = data_hol[i][2, len(data_hol[i])]
what i get is "TypeError: len() of unsized object"
any ideas ?
thanx