title: Remove empty lines from file or nested list
body: <p>I have a csv file I am putting into a empty list, line by line, so the end result is a nested list with each line in a list e.g:</p>
  
  <pre><code>[[1.1,2.6,3,0,4.8],[3.5,7.0,8.0]....and so on.....].
  </code></pre>
  
  <p>The problem is at the end of the file are empty strings which end up in the final list like:</p>
  
  <pre><code>[[1.1,2.6,3,0,4.8],[3.5,7.0,8.0],['','','','','','','','','']]
  </code></pre>
  
  <p>How do I get rid of these or stop them being appended to the list. They are quite big csv files so I would prefer to stop them being appended to intial list. I feel I am building a extra large list when I probably don't need too, and this may cause memory issues.
  Here is code so far:</p>
  
  <pre><code>csvfile = open(file_path, 'r')
  reader = csv.reader(csvfile)
  data_list = []
  
  for row in reader:
      data_list.append(row)
  csvfile.close()
  i = 0
  file_data = []
  
  while i &lt; len(data_list):
      j = 0
      while j &lt; len(data_list[i]):
          try:
              data_list[i][j] = float(data_list[i][j])
          except ValueError:
              pass            
          j += 1
      file_data.append(data_list[i])
      i += 1
  
  print file_data
  </code></pre>