gspread – Add Formula to Google Spreadsheet Cells

gspread documentation does not have any examples of adding formulas to the cells. If you try to use them with append_row or update_cell methods it records them as a string and not as a Formula.

You should instead use the update_cell method

Updating a Single Cell, considering you know the exact Row and Column Number

worksheet2.update_acell('A45','=SUM(D45:F45)')

Updating a Single Cell, considering you the exact Row and Column Number are not known

cell = worksheet2.find("David Letterman")
row_number = cell.row
workbook2_row='A'+str(row_number)

worksheet2.update_acell(workbook2_row,'=INDIRECT(CONCATENATE("D",ROW()))-INDIRECT(CONCATENATE("E",ROW()))')

Advertisements

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)

‘int’ object is not callable

If you get an error message like one of these:

TypeError: 'int' object is not callable
TypeError: 'float' object is not callable
TypeError: 'str' object is not callable

This probably means that you are trying to call a method when a property with the same name is already available.

Simply change the method call into a property access.

For example, if a line like this causes an error message like one of those above:

rowcount=worksheet1.rows()
Try changing the line to this:

rowcount=worksheet1.rows

PyInstaller Error – expected str, bytes or os.PathLike object, not NoneType

Operating System: Windows 10

Python Version: 3.7.2

PyInstaller Version: 3.4

This is a fairly annoying error without much information to go by. But luckily for us, a responsible coder has provided a solution to this.

The solution lies in making changes to the file bindepend.py in the Project Folder

<ProjectName>/venv/lib/python3.7/Pyinstaller/depend/bindepend.py

Rename the existing file to bindepend_old.py and replace this file with the one available on GitHub as provided below.

https://github.com/Loran425/pyinstaller/blob/14b6e65642e4b07a4358bab278019a48dedf7460/PyInstaller/depend/bindepend.py

Converting to exe using PyInstaller should work perfectly now.

Let me know how you fared.