title: How to populate 2D array from the file
body: <p>I have a file with one parameter per line:</p>
  
  <pre><code>a1
  b1
  c1
  a2
  b2
  c2
  ...
  </code></pre>
  
  <p>The parameters are lines of characters (not numbers)</p>
  
  <p>I need to load it to 2D array for further manipulations.
  So far I managed to upload this file into 1D array:</p>
  
  <pre><code>ParametersRaw = []
  with open(file1) as fh:
      ParametersRaw = fh.readlines()
  fh.close()
  
  NumberOfColumns = 7
  NumberOfRows = len(ParametersRaw)/NumberOfColumns
  
  Parameters = [[],[]]
  i=0
  j=0
  k=0
  while (i &lt; NumberOfRows):
      while (j &lt; NumberOfColumns):
          k = (i*NumberOfColumns)+j
          Parameters[i][j] = ParametersRaw[k]
          j = j + 1
      i = i + 1
      j = 0
  </code></pre>
  
  <p>it fails at the line <code>Parameters[i][j] = ParametersRaw[k]</code> with error:</p>
  
  <blockquote>
    <p>IndexError: index 0 is out of bounds for axis 0 with size 0</p>
  </blockquote>
  
  <p>In case of populating 1D array I would use append() method.
  But in case of 2D I am lost of how append() can be applied.</p>
  
  <p>Leonid</p>