[Python] How do I get all records from all sheets (tabs) in a google spreadsheet using one API...

Discussão em 'Python' iniciado por Stack, Julho 9, 2025.

  1. Stack

    Stack Membro Participativo

    I wanted to retrieve all the records from a google spreadsheet in one api call (instead of looping through all the sheets and retrieving them one-by-one). Currently I'm doing this

    creds = ServiceAccountCredentials.from_json_keyfile_name('path-to-key', 'key.json'), self.scope)
    client = gspread.authorize(creds)
    spread = client.open("My SpreadSheet")

    data_for_sheet_0 = spread.get_worksheet(0).get_all_records()
    data_for_sheet_1 = spread.get_worksheet(1).get_all_records()
    .
    .
    .


    As you can see, this is not efficient. Is there any way to get all of the sheet data (or the entire spreadsheet as an Iterable of Iterables)? Thanks.

    Continue reading...

Compartilhe esta Página