Here's a bit of a quick hack:
Code:
import scipy.sparse
import numpy
def read_sparse(filename):
(r, c, d) = numpy.transpose(numpy.loadtxt(filename, 'int'))
return scipy.sparse.coo_matrix((d, (r-1, c-1)))
Note that the matrix's dimensions may be truncated if there are trailing rows and columns that are all 0, but this is not the case with your example matrix. It would need a little more work to read the dimensions from the file.
---
A better approach would be to have Octave
save the data into MATLAB format (using something like
save -6 A_sparse_octave.mat A), then
read it in Python using
scipy.io.loadmat
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor