Python Google Sheets API: Append New Row

Jul 2, 2019
credentials = ...service = build('sheets', 'v4', credentials=credentials)sheet = service.spreadsheets()SPREADSHEET_ID = ...SHEET_NAME = ...# append new row on empty row from Row 2 onwardsrange_notation = f"'{SHEET_NAME}'!A2"body = {    'values': [        ['New Col 01', 'New Col 02', 'New Col 03']    ]}result = sheet.values().append(spreadsheetId=SPREADSHEET_ID,                               range=range_notation,                               body=body,                               valueInputOption="RAW",                               insertDataOption="INSERT_ROWS").execute()print(f"newRows={result['updates']['updatedRows']}")

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

NOTE: Refer Android (Java/Kotlin) Google Sheets API: Append New Row

References:

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.