title: I keep getting "NoneType object is not subscriptable"
body: <p>I am trying to write a function that will allow me to browse for a CSV file, and then parse that CSV file, before sending off each value to the Google Search API (that bit is already written).</p>
  
  <p>So right now I've got this:</p>
  
  <pre><code>def loadtemplate():
      filename = tkFileDialog.askopenfilename(filetypes = (("CSV files", "*.csv")
                                                               ,("Text Files", "*.txt")
                                                               ,("All files", "*.*") ))
      if filename: 
              try: 
                  csvfile = csv.reader(open(filename, 'rb'), delimiter=',')
                  for row in csvfile:
                      for x in row:
                              generate(x)
              except: 
                  tkMessageBox.showerror("Open Source File", "Failed to read file \n'%s'"%filename)
                  return
  </code></pre>
  
  <p>And my CSV file looks like this:</p>
  
  <pre><code>seo,company name,drupal,wordpress themes,awesome web design
  </code></pre>
  
  <p>Nothing too crazy. Anyway, I'm getting this error:</p>
  
  <pre><code>Exception in Tkinter callback
  Traceback (most recent call last):
    File "C:\Python27\lib\lib-tk\Tkinter.py", line 1410, in __call__
      return self.func(*args)
    File "C:/Python27/Projects/Google Searcher/realsearcher.py", line 20, in loadtemplate
      generate(x)
    File "C:/Python27/Projects/Google Searcher/realsearcher.py", line 31, in generate
      gs = gs['cursor']
  TypeError: 'NoneType' object is not subscriptable
  </code></pre>
  
  <p>It seems like somehow a value is being set to None? But I keep either trying to use a conditional where <code>if x == None:</code>, it'll not allow the query to go through or try to change the CSV file to where nothing like that should be parsed.</p>
  
  <p>What's going on here, and how do I fix it?</p>
  
  <p>PS - this is what the variable row looks like:</p>
  
  <pre><code>['seo', 'company name', 'drupal', 'wordpress themes', 'awesome web design']
  </code></pre>
  
  <p>Here is generate() (I used duplicate code because I felt that writing something that would do both solutions would take longer and was unnecessary because this project won't be expanded):</p>
  
  <pre><code>def generate(item):
      infoget = urllib.quote(item)
      infoquote = '"' + infoget + '"' 
      response = urllib2.urlopen("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&amp;q=" + infoget)
      gs = simplejson.load(response)
      gs = gs['responseData']
      gs = gs['cursor']
      gs = gs['estimatedResultCount']
      print gs
      response = urllib2.urlopen("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&amp;q=" + infoquote)
      gs = simplejson.load(response)
      gs = gs['responseData']
      gs = gs['cursor']
      gs = gs['estimatedResultCount']
      print gs
  </code></pre>