Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Quickest update methods

See original GitHub issue

I am using this API in a chunk of software for automated testing and uploading resulting data to a spreadsheet to share.

I am noticing some lag on uploads and I can easily work around it, but I want to make sure I am not doing it wrong or there is a much quicker way. Essentially I am updating a cell at a time. The row can change often so I figured it would be easier to go by row number over cell name like “A1”.

workSheet.update_cell(conInfo[0],1,time.strftime("%Y-%m-%d %H:%M:%S", conInfo[1]))

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:1
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

TravisJoecommented, May 28, 2013

Yes, this is many times faster, even with needing to get the objects first from the spreadsheet.

I included a chunk of my code just in case it helps others. Basically I have a queue of value that needs to get uploaded. One gets pulled off, I get the cell objects for that row, update the values from the from the queue tuple, and then upload the cell list.

row = str(queueReturn[1])
range_build = 'A' + row + ':E' + row

cell_list = workSheet.range(range_build)

cell_list[0].value = time.strftime("%Y-%m-%d %H:%M:%S", queueReturn[2])
cell_list[1].value = queueReturn[3]
cell_list[2].value = queueReturn[4]
cell_list[3].value = queueReturn[5]
if queueReturn[6] is None:
         cell_list[4].value = queueReturn[6]
         cell_list[4].value = time.strftime("%Y-%m-%d %H:%M:%S", queueReturn[6])

burnashcommented, May 27, 2013

Hi Travis,

If I get it right, you’re doing a bulk cells update and in this case the Worksheet.update_cells can be much faster.

It works this way:

# Select a cell range
cell_list = worksheet.range('A1:A7')

# Update values
for cell in cell_list:
    cell.value = "O_o"

# Send update in batch mode

It is faster because there’s only one Google API call in case of update_cells (contrary to one API call for each update_cell call). Since Spreadsheets API is not very swift, the less API calls you make the faster it goes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Methods for Updating Data
UPDATE is a batch operation that quickly modifies a small number of records. CREATE TABLE AS SELECT is a bulk operation that adds...
Read more >
How to update an Android app - Android Police
How to update Android apps using the Google Play Store · Open the Google Play Store. · In the upper-right corner, tap your...
Read more >
SQL Update statement Performance Tips
This article will show some beneficial tips about the SQL update statements ... Best practices to improve SQL update statement performance.
Read more >
Fastest Updates in SQL Server - Natural Born Coder
In this method I submit updates that modify a single cell at a time but I can submit multiple updates in a transaction....
Read more >
Fastest way to do mass update - sql - Stack Overflow
How are you doing the '50K batch records at a time' update? Is it with a stored procedure? If so, can you put...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found