将稀疏矩阵加载到python中

时间:2014-01-15 09:35:58

标签: python file-io sparse-matrix

我在R中生成了一个稀疏矩阵,并在csv中编写,看起来像

1   0   0   0 .
0   1   1   1 .
0   0   0   0 .
1   0   0   0 .
.............

等等 然后,当我试图通过 numpy.loadtext

加载csv时
 Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "C:\Python27\lib\site-packages\numpy\lib\npyio.py", line 841, in loadtxt
 items = [conv(val) for (conv, val) in zip(converters, vals)]
 ValueError: invalid literal for float(): 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

我如何阅读csv?

0 个答案:

没有答案