title: Remove empty nested lists - Python
body: <p>I'm reading in a .csv file to a list and it appends an empty lists, I'm using the code below to do this.</p>
  
  <pre><code>with open('Scores.csv', 'r') as scores:
      reader = csv.reader(scores)
      tscores = [[str(e) for e in r] for r in reader]
  </code></pre>
  
  <p>It creates a list of nested lists correctly but appends an empty list after every row read in like so:</p>
  
  <pre><code>[[score1, name1], [], [score2, name2], []]
  </code></pre>
  
  <p>I believe it's reading <code>\n</code> as an empty string which is why I'm getting that, so I tried to remove empty lists using:</p>
  
  <pre><code>tscores = [tscores.remove(x) for x in tscores if x]
  </code></pre>
  
  <p>which does delete empty nested lists, but it sets all other nested lists that contained data to <code>None</code> i.e. <code>[None, None]</code>. I modified to:</p>
  
  <pre><code>tscores = [tscores.remove(x) for x in tscores if []]
  </code></pre>
  
  <p>which wipes out all nested lists completely. </p>
  
  <p>How can I read the file with the same output (a list of nested lists) without appending empty lists or how can I remove all empty lists after being read in? </p>