[SciPy-User] Loading a CSV with loadtxt

Athanasios Anastasiou athanastasiou@gmail....
Wed Oct 27 14:19:21 CDT 2010

Hello everyone

I have a CSV file with the following format:
Unicode<100, Unicode<100, float, float, uint

and i am trying to read it into a numpy array using:

theData = numpy.loadtxt('primData.csv',delimiter=',',skiprows=1,dtype={'names':('NodeS','NodeT','flowF','flowB','ID'),'formats':('U100','U100','f','f','uint')})

This fails with "expected a readable buffer object". I have also tried
first opening the file through codecs as a utf-8 file and passing the
file object into loadtxt but i still get the same error. And i have
also tried defining the dtype outside of loadtxt and making sure that
it works before using it any further.

However, when i tried the code that is available at the cookbook:
(with some minor modifications)

It works exactly as expected.

I don't mind using the latter but i am just wondering what it is that
i am doing wrong with loadtxt(?)

Any ideas why loadtxt fails in this way?

All the best

More information about the SciPy-User mailing list