numpy.loadtxt, ValueError: could not convert string to float

You need to strip off the trailing ';' from the lines.

A possible workaround if you know you have 5 columns is:

np.loadtxt('test.csv', delimiter=";", usecols=range(5))

Or, use genfromtext instead which handles missing values

np.genfromtxt('test.csv', delimiter=";")[:,:-1]

Leave a Comment