nithinmurali / pygsheets

Google Sheets Python API v4

Home Page:https://pygsheets.readthedocs.io/en/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when appending 'This range already has a worksheet with different title set'

caynebrister1 opened this issue · comments

For some reason I get the error 'This range already has a worksheet with different title set' when running the following code:

gc = pygsheets.authorize(client_secret='auth/client_secret.json', local=True)
sh = gc.open_by_key('1rP-RKuIfkGB_qps7VclkmBEQW9T2DfwJm64UVcc-4lw')
wks = sh[1]
wks.append_table(values=['1', '2', '3'])

Ive searched the error up but cant find much on it and I am having trouble understanding what is causing the error, if anyone knows what is happening and how I might be able to fix this I would love to learn!

Couldnt figure it out so ended up just using try/except to ignore the error.

Seeing this error as well. The append seems to go through regardless.

@nithinmurali is there a workaround for this? As @caynebrister1 mentioned I have been using it with the try/except block and using the Insert Rows method to get over this.

If I am able to execute the append_table method without any error, the class becomes extremely powerful as I can write to multiple sheets from a single script.

Hello, I've just encountered this issue as well.

If you are getting this error, you are probably trying to append a single row of data as a simple list, whereas this function is expecting a list of lists (so that you could add many rows at once). If you mean to only add a single row, then just wrap your row in an additional list.

For instance @caynebrister1 could fix the code above by changing the last line to
wks.append_table(values=[['1', '2', '3']])