title: Populating google spreadsheet by row, not by cell
body: <p>I have a spreadsheet whose values I want to populate with values from dictionaries within a list. I wrote a for loop that updates cell by cell, but it is too slow and I get the gspread.httpsession.HTTPError often. I am trying to write a loop to update row by row. Thats what I have:</p>
  
  <pre><code>lstdic=[
  {'Amount': 583.33, 'Notes': '', 'Name': 'Jone', 'isTrue': False,},
  {'Amount': 58.4, 'Notes': '', 'Name': 'Kit', 'isTrue': False,},
  {'Amount': 1083.27, 'Notes': 'Nothing', 'Name': 'Jordan', 'isTrue': True,}
  ]
  </code></pre>
  
  <p>Here is my cell by cell loop:</p>
  
  <pre><code>headers = wks.row_values(1)
  
      for k in range(len(lstdic)):
          for key in headers:
              cell = wks.find(key)
              cell_value = lstdic[k][key]
              wks.update_cell(cell.row + 1 + k, cell.col, cell_value)
  </code></pre>
  
  <p>What it does is it finds a header that corresponds to the key in the list of dictionaries and updates the cell under it. The next iteration the row is increased by one, so it updates cells in the same columns, but next row. This is too slow and I want to update by row. My attempt:</p>
  
  <pre><code>headers = wks.row_values(1)
  
  row=2
  for k in range(len(lsdic)):
      cell_list=wks.range('B%s:AA%s' % (row,row))
      for key in headers: 
          for cell in cell_list:
              cell.value = lsdic[k][key]
      row+=1
      wks.update_cells(cell_list)
  </code></pre>
  
  <p>This one updates each row quickly, but with the same value. So, the third nested for loop assigns the the same value for each cell. I am breaking my head trying to figure out how to assign right values to the cells. Help appreciated.</p>
  
  <p>P.S. by the way I am using headers because I want a certain order in which values in the google spreadsheet should appear.</p>