Python Google Sheets API: Read All Rows

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

SPREADSHEET_ID = ...
SHEET_NAME = ...

range_notation = SHEET_NAME
value_render_option = 'FORMATTED_VALUE' # UNFORMATTED_VALUE, FORMULA
date_time_render_option = 'SERIAL_NUMBER' # FORMATTED_STRING
result = sheet.values().get(spreadsheetId=SPREADSHEET_ID,
                            range=range_notation,
                            valueRenderOption=value_render_option,
                            dateTimeRenderOption=date_time_render_option).execute()
values = result.get('values', [])

if not values:
    print('No data found.')
else:
    for row in values:
        print(row)

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

References:

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