Quick question for an issue I haven\'t managed to solve quickly:
I\'m working with a .csv file and can\'t seem to find a simple way to convert strings to floats. Her
Try something like the following
import csv
def read_lines():
with open('testdata.csv', 'rU') as data:
reader = csv.reader(data)
for row in reader:
yield [ float(i) for i in row ]
for i in read_lines():
print(i)
# to get a list, instead of a generator, use
xy = list(read_lines())
As for the easiest way, then I suggest you see the xlrd, xlwt modules, personally I always have hard time with all the varying CSV formats.