title: Load a Grid from a text file in python
body: <p>I have a problem with the code below. I wanted to read a text.file from python which returns a grid corresponding to the data contained in the
  file named file.  Here is the code:</p>
  
  <pre><code>import csv
  
  def loadGrid(file):
  with open("C:\ Users\ Desktop\ file.txt") as file:
      grid = []
  for gridLines in csv.reader(file):
      # The rstrip method gets rid of the "\n" at the end of each line
      grid.append(gridLines.rstrip().split("[]"))
  
  loadGrid(file)
  </code></pre>
  
  <p>I am getting this error, i have been trying to look for a solution but to no avail.</p>
  
  <p><strong>NameError: name 'file' is not defined</strong></p>
  
  <p>Thank you for your help in advance.</p>