I am try to save a matrix in R and reload in python
# R
Matrix::writeMM(data_matrix, file='/path/to/data_matrix.mtx')
# also reload to test
#data_matrix <- Matrix::readMM(file='/path/to/data_matrix.mtx')
# shell
head /path/to/data_matrix.mtx
%%MatrixMarket matrix coordinate integer general
26621 11089 32120337
1 1 1
9 1 1
14 1 1
15 1 2
18 1 3
21 1 1
34 1 2
35 1 3
# reload in python
import io
data_input = io.mmread('/path/to/data_matrix.mtx')
I got following error:
/path/to/python3.9/site-packages/scipy/io/_fast_matrix_market/__init__.py:197, in _get_read_cursor(source, parallelism)
195 ret_stream_to_close = source
...
--> 197 return _fmm_core.open_read_file(path, parallelism), ret_stream_to_close
199 # Stream object.
200 if hasattr(source, "read"):
ValueError: Line 1: Not a Matrix Market file. Missing banner.
I don’t know where the problem occurred.
1