title: How to to read a matrix from a given file?
body: <p>I have a text file which contains matrix of N * M dimensions.</p>
  
  <p>For example the input.txt file contains the following:</p>
  
  <pre class="lang-none prettyprint-override"><code>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,2,1,0,2,0,0,0,0
  0,0,2,1,1,2,2,0,0,1
  0,0,1,2,2,1,1,0,0,2
  1,0,1,1,1,2,1,0,2,1
  </code></pre>
  
  <p>I need to write python script where in I can import the matrix.</p>
  
  <p>My current python script is:</p>
  
  <pre><code>f = open ( 'input.txt' , 'r')
  l = []
  l = [ line.split() for line in f]
  print l
  </code></pre>
  
  <p>the output list comes like this</p>
  
  <pre class="lang-none prettyprint-override"><code>[['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,2,1,0,2,0,0,0,0'], ['0,0,2,1,1,2,2,0,0,1'], ['0,0,1,2,2,1,1,0,0,2'],
   ['1,0,1,1,1,2,1,0,2,1']]
  </code></pre>
  
  <p>I need to fetch the values in int form . If I try to type cast, it throws errors.</p>