Greetings Python gurus.
I'm looking for a better (faster) way to load a plaintext COO (row,column,value tuple) file into Python. The values are all integers.
File Aijv.dat is a ~7.5 MB plaintext file in COO format representing a
178420x2696 sparse matrix with 535260 non-zero entries.
Here's a portion of code showing Python taking almost 19 seconds to load Aijv.dat:
Code:
Python 2.7.5 (default, May 15 2013, 22:43:36)
[MSC v.1500 32 bit (Intel)] on win32
>>> import numpy
>>> import time
>>> import scipy
>>> import scipy.sparse as sp
>>> import scipy.sparse.linalg
>>> start=time.time()
>>> Aijv = numpy.loadtxt('Aijv.dat', 'int')
>>> time.time()-start
18.844000101089478
The exact same file takes only 5.5 seconds to load in Octave:
Code:
GNU Octave, version 3.6.4
+ tic;
+ Aijv = dlmread ('Aijv.dat');
+ toc
Elapsed time is 5.547 seconds.