Pygsheets – Adding Data to Google Spreadsheets

I was facing a 5 second time delay adding data to Google Spreadsheets while using the gpread library. Web search revealed the same with other users as well.

Web search led me to pygsheets, a user seemed to claim that it is much faster when writing data into Google Spreadsheets, but my experience has been different.

Pygsheets takes a minimum 9 seconds to save a record compared to 5 seconds with gpread. If a coder has had a better experience, kindly do share your feedback.

There are few tutorials online for pygsheets, I am assuming the slowness of the system might be the reason.

import pygsheets
from oauth2client.service_account import ServiceAccountCredentials

scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)

client = pygsheets.authorize(service_file='client_secret.json')
workbook = client.open("Spreadsheet_File_Name")

worksheet1 = workbook.worksheet_by_title("Sheet1")

rowcount=worksheet1.rows

row_value=['a','b','c']

worksheet1.insert_rows(row=rowcount,number=1, values=row_value,inherit=True)

#worksheet1.add_rows(1)
#worksheet1.update_row(rowcount+1,values=row_value)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s