title: TypeError: 'generator' object has no attribute '__getitem__'
body: <p>I have written a generating function that should return a dictionary. however when I try to print a field I get the following error</p>
  
  <pre><code>print row2['SearchDate']
  TypeError: 'generator' object has no attribute '__getitem__'
  </code></pre>
  
  <p>This is my code</p>
  
  <pre><code>from csv import DictReader
  import pandas as pd
  import numpy as np
  
  
  def genSearch(SearchInfo):
      for row2 in DictReader(open(SearchInfo)):
          yield row2
  
  train = 'minitrain.csv'
  
  SearchInfo = 'SearchInfo.csv'
  
  row2 = {'SearchID': -1}
  
  for row1 in DictReader(open(train)):
      if 'SearchID' in row1 and 'SearchID' in row2 and row1['SearchID'] == row2['SearchID']:
          x = deepcopy( row1 )
          #x['SearchDate'] = row2['percent']
          x.update(row2)    
          print 'new'
          print x
      else: 
          #call your generator
          row2 = genSearch(SearchInfo)
          print row2['SearchDate']
  </code></pre>