Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
caynebrister1 opened this issue Feb 9, 2023 · 6 comments

Comments

@caynebrister1
Copy link

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!

@caynebrister1 caynebrister1 changed the title Error when apending 'This range already has a worksheet with different title set' Error when appending 'This range already has a worksheet with different title set' Feb 9, 2023
@caynebrister1
Copy link
Author

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

@Vanifac
Copy link

Vanifac commented Feb 17, 2023

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

@CodeBiriyani
Copy link

@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.

@Jacoba777
Copy link

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']])

@Anthony-Marcovecchio
Copy link

Anthony-Marcovecchio commented Jun 21, 2024

@Jacoba777 Experiencing the same issue noted above, ensuring values is a list of lists does not resolve the 'This range already has a worksheet with different title set' message on my end. Using worksheet.insert_rows(row=1, number=1, values=[ [1, 2, 3]]) pushes the data successfully but without that error message. Hope this helps

@SamLiCN
Copy link

SamLiCN commented Sep 26, 2024

Hello, I met similar case, it solved after I remove the space in the "sheet title";
in my case, append_table can add new row to Google Sheet, the error in the return value
{
"spreadsheetId": string,
"tableRange": string,
"updates": {
object (UpdateValuesResponse)
}
}
the "tableRange" value for sheet title has extra quote "''".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants