[SciPy-user] Creating a sparse matrix

Alan G Isaac aisaac@american....
Thu Dec 13 07:26:06 CST 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