-
Notifications
You must be signed in to change notification settings - Fork 950
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
Update examples of gspread usage /Readme.md #1410
Comments
Hi. Thanks for the issue :) Do you refer to this section of the readme? Lines 263 to 267 in 4a48fbd
I notice that this section is wrong. I think it should be # Update a single cell
-worksheet.update('B1', 'Bingo!')
+worksheet.update_acell('B1', 'Bingo!')
# Update a range
-worksheet.update('A1:B2', [[1, 2], [3, 4]])
+worksheet.update([[1, 2], [3, 4]], 'A1:B2') I think that all functions in the readme should be tested to make sure they work, as that is the most important part of documentation to get right. This could be as a part of #1413 |
Yes , dont know about range but yes for the single one |
reopening as I don't think this is changed yet |
I have some problems with updating single cell. from selenium import webdriver
from google.oauth2.service_account import Credentials
import gspread
from humanfriendly import parse_size
from selenium import webdriver
from selenium.webdriver.common.by import By
scopes = [
'https://www.googleapis.com/auth/spreadsheets',
'https://www.googleapis.com/auth/drive'
]
credentials = {
******
}
likes=[]
comments=[]
saves=[]
shares=[]
gc = gspread.service_account_from_dict(credentials)
sht2 = gc.open_by_url('https://docs.google.com/spreadsheets/d/1zZFqgrN6A4JNIlftQgpbyMHBZadfefFWsU7LpL_BBrwQxu6E/edit?usp=sharing')
worksheet = sht2.get_worksheet(0)
worksheet.update('B1', 'Bingo!') I got an error. I ever done this in the last week before but the scripts are working. gspread.exceptions.APIError: {'code': 400, 'message': 'Invalid value at \'data.values\' (type.googleapis.com/google.protobuf.ListValue), "A2"', 'status': 'INVALID_ARGUMENT', 'details': [{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'data.values', 'description': 'Invalid value at \'data.values\' (type.googleapis.com/google.protobuf.ListValue), "A2"'}]}]}
PS C:\Users\Lenovo\Desktop\code\tiktoka-data-mcn>
PS C:\Users\Lenovo\Desktop\code\tiktoka-data-mcn>
PS C:\Users\Lenovo\Desktop\code\tiktoka-data-mcn>
PS C:\Users\Lenovo\Desktop\code\tiktoka-data-mcn> python '.\test,py'
Traceback (most recent call last):
File "C:\Users\Lenovo\Desktop\code\tiktoka-data-mcn\test,py", line 34, in <module>
worksheet.update('B1', 'Bingo!')
File "C:\Users\Lenovo\AppData\Roaming\Python\Python311\site-packages\gspread\worksheet.py", line 1239, in update
response = self.client.values_update(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Lenovo\AppData\Roaming\Python\Python311\site-packages\gspread\http_client.py", line 168, in values_update
r = self.request("put", url, params=params, json=body)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Lenovo\AppData\Roaming\Python\Python311\site-packages\gspread\http_client.py", line 123, in request
raise APIError(response)
gspread.exceptions.APIError: {'code': 400, 'message': 'Invalid value at \'data.values\' (type.googleapis.com/google.protobuf.ListValue), "B1"', 'status': 'INVALID_ARGUMENT', 'details': [{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'data.values', 'description': 'Invalid value at \'data.values\' (type.googleapis.com/google.protobuf.ListValue), "B1"'}]}]} |
Hi. Apologies for the delay. Please change your code to - worksheet.update("B1", "Bingo!")
+ worksheet.update_acell("B1", "Bingo!") and let me know if this works? We will update the readme to reflect this soon :) Thanks. p.s. to @lavigne958: are the arguments of |
yes they are ! 😞 the method
the method `update_acell is
|
nice how did this happen |
I would say it's historic, left over from the past from this repository I suppose. |
Hi,
Their is no usage example of single cell update in the Read me as the example currently is not complete .
simple add worksheet.update_acell('A1', 'Bingo!') to the updating cell example
The text was updated successfully, but these errors were encountered: