saving numpy matrix in text file with indices
<p>I am trying to save a 2D matrix A to text file for each non-zero entry.  I would like to save it in the below format, </p>

<p>For the (i,j)-th entry, one line as </p>

<pre><code>row[i]::column[j]::A[i,j]
</code></pre>

<p>where row and column are 1D numpy array corresponding to rows and column indices</p>

<p>I tried,  </p>

<pre><code>np.savetxt(rel_file,(row,column,A),fmt='%d',delimiter="::",newline="\n");
</code></pre>

<p>But, since shape mismatches, i get error.  I do not want to iterate over each row and column indices in a loop (I think it is too time consuming, i have 5000*5000 matrix).</p>