Search code examples
pythongoogle-sheets-apipygsheets

Proper usage of list_ssheets() with a parent_id in pygsheets


I've been trying to get a handle on how to use list_ssheets() with a parent_id filter.

The following works well, and returns a list of all the sheets (including the ones I'm trying to isolate from a folder):

the_list_of_sheets = gc.list_ssheets()

list_ssheets() on its own works well and returns all of the sheets, but the follow returns an empty list (the xxxx being the containing folder id):

the_list_of_sheets = gc.list_ssheets('xxxxxxxxxxxxxxxxxxxxxxxxxxx')

I've tried a number of different ways to get this to work, but can't seem to hit the right syntax.

What is the proper way to use list_ssheets() with a parent_id to return all sheets in a particular directory?

Thanks!


Solution

  • Thank you tehhowch, I think I sorted it out.

    While the sheets within my target folder were shared with my pgysheets account, the folder itself was not! Silly mistake, but happy to have solved it.

    <directory xxxxxxxxxxx>  (must be shared!)
        <file 1>  (shared!)
        <file 2>  (not shared!)
        <file 3>  (shared!)
    

    So now,

    the_list_of_sheets = gc.list_ssheets('xxxxxxxxxxx')
    

    Returns a list with file 1 and file 3. Yay!