views:

134

answers:

1

Hi, I wonder if there is a direct way to import the contents of a csv file into a record array, much in the way that R's read.table(), read.delim(), and read.csv() family imports data to R's data frame? Or is the best way to use csv.reader() and then apply something like numpy.core.records.fromrecords()?

+4  A: 

You can use Numpy's genfromtxt() method to do so, by setting the delimiter kwarg to a comma.

from numpy import *
my_data = genfromtxt('my_file.csv', delimiter=',')

More information on the function can be found at its respective documentation.

Andrew
Works great! Thanks
Stephen