tidyverse / googlesheets4

Google Spreadsheets R API (reboot of the googlesheets package)
https://googlesheets4.tidyverse.org
Other
357 stars 51 forks source link

cannot specify a specific sheet in the URL #279

Closed alusiani closed 1 year ago

alusiani commented 1 year ago

The Getting Started section of the documentation sort of hints that one can use a URL to select a specific sheet of a Google spreadsheet:

# URL
read_sheet("https://docs.google.com/spreadsheets/d/1U6Cf_qEOhiR9AZqTqS3mbMF3zt2db48ZP5v3rkrAEJY/edit#gid=780868077")
#> ✔ Reading from "gapminder".
#> ✔ Range 'Africa'.
#> # A tibble: 624 × 6
...

One can get the same data using the main URL without the "/edit#gid=780868077" addition however. And if one rather uses

read_sheet("https://docs.google.com/spreadsheets/d/1U6Cf_qEOhiR9AZqTqS3mbMF3zt2db48ZP5v3rkrAEJY/edit#gid=45759261")

to get America instead of Africa one gets again Africa, i.e. the "#gid=45759261" is just apparently discarded.

From the documentation, it is not clear whether a specific sheet can be indicated in the URL. I would recommend to mention in the documentation and in "Getting Started" that the "#..." string is not used in the URL, or else implement the functionality of using it.

jennybc commented 1 year ago

Yeah, we currently don't recover anything beyond the overall sheet ID from a URL. Partially because we don't have a data structure more general than sheet_id to hold two (or three) pieces of information instead of just one. I consider the feature request part of this as covered by #3 and #88.

alusiani commented 1 year ago

OK, thanks for the quick reply.