Search code examples
pythongoogle-sheets-apigspread

does this library assume the Google Spreadsheet will have one sheet only?


I am trying to use this library to pull data from a Googlespreadsheet with two sheets in it, I can get data only from the first sheet but not the second sheet. sheet = client.open("sheetname").sheet1, if I change sheet1 to sheet2 I get the following error sheet = client.open("filename").sheet2 AttributeError: 'Spreadsheet' object has no attribute 'sheet2' how do I fix this? any help is appreciated!


Solution

  • .sheet1 is used as a shortcut.

    In order to get the second sheet try that:

    sheet = client.open("filename").get_worksheet(1)
    

    1 means second sheet (starting from 0).

    References: