[SciPy-user] Creating a sparse matrix

Alan G Isaac aisaac at american.edu
Thu Dec 13 08:26:06 EST 2007


On Thu, 13 Dec 2007, Nils Wagner apparently wrote:
> How can I do that on-the-fly ? 

That depends on the file format.
But are you just asking if you can do the following?

data = []
for row in open(filename,'r'):
    r0, r1, r2 = row.split()
    data.append( [int(r0), int(r1), float(r2)] )

Cheers,
Alan Isaac






More information about the SciPy-User mailing list