-
Notifications
You must be signed in to change notification settings - Fork 948
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
Add insert_note feature (#50) #818
Add insert_note feature (#50) #818
Conversation
Add the 'insert_note' and 'clear_note' feature. Notice: The request to set a note on a cell with an empty string clears the note. The 'insert_note' function only accepts string as note content Signed-off-by: Lavigne958 <lavigne958@gmail.com>
Before merge, Can someone run the tests suite please ? I tried but I could not run it, I can not figure out the Oauth google service system.... I can connect to my spreadSheets but can not run the test suite with my credentials :-( |
Sure, I'll run the tests suite before I merge it. Thank you very much for the PR. |
Hi, I managed to run the tests on my machine and it worked, and they all passed, good to go :-) |
Hi it has been a while isnce this PR is ready. I just give you a heads up in case. |
@lavigne958 sorry for the pause, looking at it now. |
Works like a charm. Thank you very much again! |
First off: thanks to burnash for the whole gspread, it's been not only terribly useful, but fun to use. Re: lavigne958's question about getting the note... from oauth2client.service_account import ServiceAccountCredentials
from googleapiclient import discovery
scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name(filename, scope)
service = discovery.build('sheets', 'v4', credentials=creds) With that fields = 'sheets/data/rowData/values/note'
ranges = [gspread.models.absolute_range_name(sheet.title, "A1")]
request = service.spreadsheets().get(spreadsheetId=sheet.spreadsheet.id, ranges=ranges, fields=fields)
note_json = request.execute()
try:
note = note_json['sheets'][0]['data'][0]['rowData'][0]['values'][0]['note'] # <-- there's got to be a better way
except KeyError:
note = None
print(note) I was hoping to incorporate this into the Cell model, so that it could be 'just another field' in the Cell (e.g. |
Hi @billga, to be honest I did not think about getting a note in gspread but only creating/updating/deleting a note. I could have a look to it. Thank you for pointing out the missing accessor. |
Closes: #50
Add the 'insert_note' and 'clear_note' feature.
Notice:
The request to set a note on a cell with an empty string clears the note.
The 'insert_note' function only accepts string as note content
In the test I add I wanted to insert a note and some how through a different process check that the note is inserted but I could not find a way to verify the presence of the note.
I ran a couple of tests myself:
Credits:
Thanks to @archeg that first provided a solution
Thanks to @hexvolt that provided the source code adapted to gpsread
Signed-off-by: Lavigne958 lavigne958@gmail.com