Python Google Sheets API: Update Cell Data

July 2, 2019
credentials = ...
service = build('sheets', 'v4', credentials=credentials)
sheet = service.spreadsheets()

SPREADSHEET_ID = ...
SHEET_NAME = ...

range_notation = "'{SHEET_NAME}'!B1"
value = 'Hello'

body = {
    'value_input_option': 'USER_ENTERED', # RAW
    'data': [
        {'range': range_notation, 'values': [[value]]}
    ]
}

result = sheet.values().batchUpdate(spreadsheetId=SPREADSHEET_ID,
                                    body=body).execute()

NOTE: Refer Setup and Access Google Sheets API With Python.

NOTE: Refer Android (Java/Kotlin) Google Sheets API: Update Cell Value

References:

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.