I have a .txt(data.txt) file containing csv data like:
X Class
15.0001 Yes
18.00 NO
17.07 Yes
I need to make a function to return a list of tuples of each samples. So far I did:
import csv
def readAllData(str):
with open(str,'r') as f:
f.readline()
data=[tuple(line) for line in csv.reader(f)]
return (data)
Output:
[('15.001\tYES',),
('18.00\tNo',),
('17.07\tYes',),]
I want:
[(15.001, Yes), (18.00, No), (17.07, Yes)]