I am reading from a file.txt which has discrete data of Node id's and their respective x-axis and y-axis positions in each line:
Node_1 20.00 35.50
Node_2 77.00 21.40
Node_3 43.50 98.30
Now, I want to read this data to form lists in python script.py:
Node_1 = [20.00 , 35.50]
Node_2 = [77.00 , 21.40]
Node_3 = [43.50 , 98.30]
nodes = [Nodes_1, Nodes_2, Nodes_3]
So ultimately I will be having a list for nodes like [ [20.00 , 35.50] , [77.00 , 21.40] ,[43.50 , 98.30] ].
I have tried it using this below python code:
inputlist = list()
fhand = open('file.txt','r')
for line in fhand:
for word in line.split():
inputlist.append(word)
//Value in inputlist[0]// = [inputlist[1],inputlist[2]]
nodes.append(inputlist[0])
del inputlist[:]
I am not finding the right way to fill the value inside inputlist[0] with the correct choice of python code.