Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8691803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:11:52+00:00 2026-06-13T00:11:52+00:00

I am trying to update or insert cells into a google spreadsheet, this is

  • 0

I am trying to update or insert cells into a google spreadsheet, this is my first time using the google api and python, so i have probably done something noddy.. but i cant see it for the life of me.

Currently my code updates existing cells but does not insert new cells,(blank cells stay blank) when i comment out “batchRequest.AddInsert(newCell)”
but when its left in I get a returned status code 500 and a heap of xml, that is little help.

The code(part)

def setRowEntries(self, cohort_key=None):
  cohort = self.GetCohort(cohort_key)

  gd_client = gdata.spreadsheet.service.SpreadsheetsService()
  gd_client.email = email
  gd_client.password = password
  gd_client.source = 'YOUR_APP_NAME'

  # LOGIN
  try:
    # log in
    gd_client.ProgrammaticLogin()
  except socket.sslerror, e:
    logging.error('Spreadsheet socket.sslerror: ' + str(e))
    return False

  # KEY FOR SHEET
  key = '0At**************************Gc'

  # LOOKUP FOR WORKSHEET KEY
  GID_TABLE = {
    'android_users_by_week_by_registration' : 'od6'
  }

  wksht_id =''
  wksht_id = GID_TABLE[cohort_key]

  #  create a cells feed and batch request
  cells = gd_client.GetCellsFeed(key, wksht_id)
  batchRequest = gdata.spreadsheet.SpreadsheetsCellsFeed()

  #TODO SET TITLE

  #resize worksheet
 # cells.col_count = len(cohort[0])
 # cells.row_count = len(cohort)

  rowcursor = 0
  for myrow in cohort:
    colcursor = 0
    #print ("row ::"+str(myrow))
    for mycell in myrow:
      #print ("cell::"+str(mycell))
      found = 0
      #print ("try and place"+str(rowcursor)+','+str(colcursor))
      for myentry in cells.entry:
        if ((int(myentry.cell.row) == int(rowcursor+1)) and (int(myentry.cell.col) == int(colcursor+1))):
          print "updating  "+myentry.cell.text+" to "+str(mycell)
          myentry.cell.inputValue = str(mycell)
          batchRequest.AddUpdate(myentry)
          found = 1

      if not found:
        print "inserting "+str(mycell)+" at Cell "+ str(rowcursor+1)+'_'+str(colcursor+1)
        newCell = gdata.spreadsheet.SpreadsheetsCell()
        newCell.cell = gdata.spreadsheet.Cell(inputValue=str(mycell), text=None, row=str(rowcursor+1), col=str(colcursor+1))
        print newCEll.inpu
        batchRequest.AddInsert(newCell)# the broken part
      colcursor = colcursor + 1
    rowcursor = rowcursor + 1

  updated = gd_client.ExecuteBatch(batchRequest, cells.GetBatchLink().href)

  if updated:
    print "Sucessfull!"+str(updated)
  else:
    print "Failed!"

The Error(part)

type="text">Internal Error</ns0:content><ns1:id xmlns:ns1="http://schemas.google.com/gdata/batch">1626</ns1:id><ns0:title type="text">Error</ns0:title><ns1:status code="500" reason="Internal Error" xmlns:ns1="http://schemas.google.com/gdata/batch" /><ns1:operation type="insert" xmlns:ns1="http://schemas.google.com/gdata/batch" /><ns0:updated>2012-10-17T09:39:18.946Z</ns0:updated></ns0:entry><ns0:entry><ns0:id>1627</ns0:id><ns0:content type="text">Internal Error</ns0:content><ns1:id xmlns:ns1="http://schemas.google.com/gdata/batch">1627</ns1:id><ns0:title type="text">Error</ns0:title><ns1:status code="500" reason="Internal Error" xmlns:ns1="http://schemas.google.com/gdata/batch" /><ns1:operation type="insert" xmlns:ns1="http://schemas.google.com/gdata/batch" /><ns0:updated>2012-10-17T09:39:18.946Z</ns0:updated></ns0:entry><ns0:entry><ns0:id>1628</ns0:id><ns0:content type="text">Internal Error</ns0:content><ns1:id xmlns:ns1="http://schemas.google.com/gdata/batch">1628</ns1:id><ns0:title type="text">Error</ns0:title><ns1:status code="500" reason="Internal Error" xmlns:ns1="http://schemas.google.com/gdata/batch" /><ns1:operation type="insert" xmlns:ns1="http://schemas.google.com/gdata/batch" /><ns0:updated>2012-10-17T09:39:18.946Z</ns0:updated></ns0:entry><ns0:entry><ns0:id>1629</ns0:id><ns0:content type="text">Internal Error</ns0:content><ns1:id xmlns:ns1="http://schemas.google.com/gdata/batch">1629</ns1:id><ns0:title type="text">Error</ns0:title><ns1:status code="500" reason="Internal Error" xmlns:ns1="http://schemas.google.com/gdata/batch" /><ns1:operation type="insert" xmlns:ns1="http://schemas.google.com/gdata/batch" /><ns0:updated>2012-10-17T09:39:18.946Z</ns0:updated></ns0:entry><ns0:entry><ns0:id>1630</ns0:id><ns0:content 

I found the google api docs very hard to understand and examples were few and too narrowly scoped. If you could let me know what im doing wrong that would be great

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:11:53+00:00Added an answer on June 13, 2026 at 12:11 am

    Reason became clear when viewing the xml in chrome , Insert not supported on batch., looks like new cells have to go in via a worksheet feed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to do an insert, I have: jdbcTemplate.update(insert into...., new Object[]{foo.getId(), foo.getName()}) foo.getId() returns
I'm trying to insert status update into my database in table called blabbing, but
I am trying to perform a update/insert into query for MySQL. Should insert, if
I'm trying to insert a large collection of objects into a table using fluent
I'm trying to update the Insert action while inserting a new element into an
I'm trying to do a single row insert/update on a table but all the
I am trying work out with MERGE statment to Insert / Update Dimension Table
I am trying update text views while this loop is processing. Here is my
I`m trying to update time in datetime field as UPDATE table_name SET col_name=to_DATE('04/02/2012 00:12:00','MM/DD/YYYY
I'm trying to use python-gdata to populate a worksheet in a spreadsheet. The problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.