[SciPy-User] Read matrix from matrix market format file

Valène Pellissier Valene.Pellissier at cedrat.com
Thu Jun 6 12:48:12 EDT 2013


Sorry I found out the problem. Blanks ...

Do you know an easy and fast way to delete the useless blanks, and still keep the ones to seperate the variables ?
My file looks like that :
%%MatrixMarket matrix coordinate real symmetric
        8176        8176       50823
           1           1   1.00000000000000
           2           1  3.217746558609426E-002
           3           1 -5.773555991094832E-002
          15           1  5.773555991029918E-002
          16           1 -2.670364769384909E-002
          50           1  2.666074407522187E-002
          51           1  0.203221218356395
          58           1 -0.203221218355300
          65           1  5.555410250046564E-004
          66           1  0.147340602419819
          69           1 -3.939755803017718E-003
         122           1 -0.147340602419818
         123           1  3.939755803017390E-003
         124           1 -5.359343846466105E-004
         125           1 -0.175978855055765
        3897           1  1.844398988268397E-003
        3931           1 -6.804457799602319E-004
        4146           1  6.804457843076172E-004


Thanks a lot for you help !

[cid:image001.jpg at 01CE62E6.63D1D860]Valène PELLISSIER - R&D Engineer
CEDRAT S.A.
15 Chemin de Malacher - Inovallée - 38246 MEYLAN cedex - FRANCE
Phone: +33 (0)4 76 90 50 45 - Fax: +33 (0)4 56 38 08 30
valene.pellissier at cedrat.com<mailto:valene.pellissier at cedrat.com> - www.cedrat.com<http://www.cedrat.com> [youtube] <http://www.youtube.com/user/CEDRATSOFTWARE> <http://www.linkedin.com/company/cedrat?trk=tabs_biz_home> [youtube] <http://www.facebook.com/pages/CEDRAT/174895345915549?sk=wall>
De : scipy-user-bounces at scipy.org [mailto:scipy-user-bounces at scipy.org] De la part de Roban Kramer
Envoyé : jeudi 6 juin 2013 15:47
À : SciPy Users List
Objet : Re: [SciPy-User] Read matrix from matrix market format file

Can you send the first few lines of the my_matrix.mtx file?

On Thu, Jun 6, 2013 at 9:05 AM, Valène Pellissier <Valene.Pellissier at cedrat.com<mailto:Valene.Pellissier at cedrat.com>> wrote:
Hi,

I've got some problems reading a matrix  from a matrix market format file.
I have Python 3.2 and installed Numpy 1.7.1, Scipy 0.12.0 and matplotlib 1.2.1 on Windows 64.
I tried the scipy.io.mmread function but got an error I don't understand.

>>> B=scipy.io.mmread("my_matrix.mtx")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python32\lib\site-packages\scipy\io\mmio.py", line 70, in mmread
    return MMFile().read(source)
  File "C:\Python32\lib\site-packages\scipy\io\mmio.py", line 301, in read
    self._parse_header(stream)
  File "C:\Python32\lib\site-packages\scipy\io\mmio.py", line 337, in _parse_he
der
    self.__class__.info(stream)
  File "C:\Python32\lib\site-packages\scipy\io\mmio.py", line 208, in info
    raise ValueError("Header line not of length 3: " + line)

It is a big matrix.
Is there someone who has a clue about what I'm doing wrong ?

Your help will be much appreciated.
Thanks
Valene

[cid:image001.jpg at 01CE62E6.63D1D860]Valène PELLISSIER - R&D Engineer
CEDRAT S.A.
15 Chemin de Malacher - Inovallée - 38246 MEYLAN cedex - FRANCE
Phone: +33 (0)4 76 90 50 45<tel:%2B33%20%280%294%2076%2090%2050%2045> - Fax: +33 (0)4 56 38 08 30<tel:%2B33%20%280%294%2056%2038%2008%2030>
valene.pellissier at cedrat.com<mailto:valene.pellissier at cedrat.com> - www.cedrat.com<http://www.cedrat.com> [youtube] <http://www.youtube.com/user/CEDRATSOFTWARE> [youtube] <http://www.facebook.com/pages/CEDRAT/174895345915549?sk=wall>

_______________________________________________
SciPy-User mailing list
SciPy-User at scipy.org<mailto:SciPy-User at scipy.org>
http://mail.scipy.org/mailman/listinfo/scipy-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20130606/cacb2d63/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 1014 bytes
Desc: image002.png
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20130606/cacb2d63/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 1130 bytes
Desc: image003.png
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20130606/cacb2d63/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 4777 bytes
Desc: image001.jpg
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20130606/cacb2d63/attachment.jpg>


More information about the SciPy-User mailing list