I have the following code:
clusters = open('input.txt', 'r')
cluster = raw_input('Enter the name of the cluster: ')
name = []
a = []
b = []
d = []
e = []
c = []
f = []
g = []
h = []
for line in clusters:
column = line.split()
name.append(column(0))
if name == cluster:
a.append(int(column(1)))
b.append(int(column(2)))
d.append(int(column(3)))
e.append(int(column(4)))
c.append(int(column(5)))
f.append(int(column(6)))
g.append(float(column(7)))
h.append(float(column(8)))
else:
print('Cluster data does not exist')
I am trying to use the first word of the file as a filter so that if it matches the input it will read the rest of the data from that line. However, when I run it I get an error saying:
File "C:/Users/Keith/.spyder2/CMD.py", line 41, in <module>
name = column(0)
TypeError: 'list' object is not callable
I have looked at a few questions which show how to print a word but I don't know how to just read it and see if it matches the input word.
My input file is like this:
fjji 38 427 18 404 46 630000 0.482 0.271
fjjii 38 481 18 159 35 630000 0.482 0.271
fjjiii 39 38 19 575 41 630000 0.504 0.284
fjjiv 39 122 22 482 35 630000 0.527 0.296
fjjv 39 134 23 49 40 630000 0.529 0.298
fjjvii 39 184 23 36 50 630000 0.527 0.296
Any help would be greatly appreciated, thanks.