[SciPy-user] Automatically retreiving Matrix Market files

Nils Wagner nwagner at mecha.uni-stuttgart.de
Thu Nov 11 08:39:47 EST 2004


Pearu Peterson wrote:

>
>
> On Thu, 11 Nov 2004, Nils Wagner wrote:
>
>> Hi all,
>>
>> I am going to retreive test matrices from the Matrix Market page
>>
>> from scipy import *
>> from tempfile import mktemp
>> from urllib import urlretrieve
>> url="http://math.nist.gov/MatrixMarket/data/SPARSKIT/fidap"
>> fname =  mktemp(".mtx.gz")
>> print "Downloading Matrix Market; this may take a minute..."
>> urlretrieve(url, fname)
>>
>> How can I decompress the file afterwards and how do I use
>>
>> io.mmread()
>>
>> to import the matrix under consideration.
>
>
> Try:
>
>   import gzip
>   io.mmread(gzip.open(fname))
>
> Pearu


Hi Pearu,

from scipy import *
from tempfile import mktemp
from urllib import urlretrieve
import os
path = os.path.join(os.environ['HOME'], 'matrices')
import gzip

url="ftp://math.nist.gov/pub/MatrixMarket2/SPARSKIT/fidap/fidap005.mtx.gz"
fname =  mktemp(".mtx.gz")
print "Downloading Matrix Market; this may take a minute..."
urlretrieve(url, fname)
A = io.mmread(gzip.open(fname))

Now it works fine. Thank you very much !

BTW, how can I remove the *.mtx.gz files in /tmp automatically ?

Nils

>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user



 





More information about the SciPy-User mailing list