I want to create a list of tuples and have this table:
Nr Name Value F/R
1 6347_sx 123.98 F
2 hff_475 234.99 F
3 sjdh_65 123.67 R
4 6347_sx 345.12 R
And I want a list like this:
norm_list = [('6347_sx',123.98), ('hff_475',234.99), ('sjdh_65',123.67), ('6347_sx',345.12)]
I try this but it did not give me the desired output:
norm_file = open("table.txt")
norm_list = []
for norm_line in norm_file.readlines():
norm_file_elements = norm_line.split()
x = norm_file_elements[1]
y = norm_file_elements[2]
norm_list= [(x,y)]
print(norm_list)
y values have to be int. Thank you for any help.
norm_list = [tuple(line.split()[1:3]) for line in norm_file]