Newbie - converting csv files to arrays in NumPy - Matlab vs. Numpy comparison

Travis E. Oliphant oliphant.travis at ieee.org
Fri Jan 12 00:59:43 EST 2007


oyekomova wrote:
> Thanks for your help. I compared the following code in NumPy with the
> csvread in Matlab for a very large csv file. Matlab read the file in
> 577 seconds. On the other hand, this code below kept running for over 2
> hours. Can this program be made more efficient? FYI - The csv file was
> a simple 6 column file with a header row and more than a million
> records.
> 
> 

There is some facility to read simply-formatted files directly into NumPy.

You might try something like this.

numpy.fromfile('somename.csv', sep=',')

and then reshape the array.

-Travis




More information about the Python-list mailing list