Issue
Is there a direct way to import the contents of a CSV file into a record array, just like how R's read.table()
, read.delim()
, and read.csv()
import data into R dataframes?
Or should I use csv.reader()
and then apply numpy.core.records.fromrecords()
?
Solution
Use numpy.genfromtxt()
by setting the delimiter
kwarg to a comma:
from numpy import genfromtxt
my_data = genfromtxt('my_file.csv', delimiter=',')
Answered By - Andrew
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.