title: read data from file to a 2d array [Python]
body: <p>I have a file .txt like this:</p>
  
  <pre><code>8.3713312149,0.806817531586,0.979428482338,0.20179159543
  5.00263547897,2.33208847046,0.55745770379,0.830205341157
  0.0087910592556,4.98708152771,0.56425779093,0.825598658777
  </code></pre>
  
  <p>and I want data to be saved in a 2d array such as</p>
  
  <pre><code>array = [[8.3713312149,0.806817531586,0.979428482338,0.20179159543],[5.00263547897,2.33208847046,0.55745770379,0.830205341157],[0.0087910592556,4.98708152771,0.56425779093,0.825598658777]
  </code></pre>
  
  <p>I tried with this code </p>
  
  <pre><code>#!/usr/bin/env python
  
  checkpoints_from_file[][]
  
  def read_checkpoints():
      global checkpoints_from_file
      with open("checkpoints.txt", "r") as f:
          lines = f.readlines()
          for line in lines:
              checkpoints_from_file.append(line.split(","))
          print checkpoints_from_file
  
  
  if __name__ == '__main__':
      read_checkpoints()
  </code></pre>
  
  <p>but it does not work.
  Can you guys tell me how to fix this? thank you</p>