Как читать комментарии из ячеек Google? - PullRequest
2 голосов
/ 23 апреля 2019

Я хочу получить доступ к данным из закомментированной ячейки в листах Google. Я проделал некоторую работу и смог получить доступ к значению в ячейке.

from oauth2client.service_account import ServiceAccountCredentials
import json

scope = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']

credentials = ServiceAccountCredentials.from_json_keyfile_name('WorkSheet001-4d8ce6dbd79f.json', scope)

gc = gspread.authorize(credentials)
wks = gc.open_by_url('https://docs.google.com/spreadsheets/d/1ME7WatXOmSEytwu7Qxem-a6BzCew36RKmD7KdhKMwbA/edit#gid=0').sheet1

print(wks.cell(2, 2).value)

print(wks.get_all_records())

Я хочу данные из прокомментированной ячейки. хотите получить доступ к данным, таким как время, дата и комментарий к ячейке и т. д.

[{'name': 'Naresh', 'technology': 'Php'}, {'name': 'kuldeep', 'technology': 'python'}]

1 Ответ

0 голосов
/ 24 апреля 2019

Вы можете попробовать библиотеку Sheetfu для этого типа задачи, в частности, используя модуль таблицы.

from sheetfu import Table

spreadsheet = SpreadsheetApp('path/to/secret.json').open_by_id('<insert spreadsheet id here>')
data_range = spreadsheet.get_sheet_by_name('people').get_data_range()

table = Table(data_range, notes=True)

for item in table:
    if item.get_field_note('name'):
        # DO SOMETHING IF THERE IS A NOTE ON FIELD NAME
        item.set_field_note('name', 'your note')

table.commit()
...