Search code examples
python-3.xgoogle-sheetsgoogle-sheets-apipygsheets

How to access renamed google sheets


I have a google sheets workbook whose sheets get continuously re-ordered. I am able to read each sheet using wks = gc.open("DatSheet").sheet1, but this will always get data from the sheet in first position. How can i use individual sheet names to access them, for example: wks = gc.open("DatSheet").uniquename?


Solution

  • You can use the worksheet function to get a worksheet based on title, index or id. Or you can just use worksheet_by_title.

    So in your case

    gc.open("DatSheet").worksheet_by_title("sheet name")