View source: R/range_speedread.R
range_speedread | R Documentation |
This function uses a quick-and-dirty method to read a Sheet that bypasses the
Sheets API and, instead, parses a CSV representation of the data. This can be
much faster than range_read()
– noticeably so for "large" spreadsheets.
There are real downsides, though, so we recommend this approach only when the
speed difference justifies it. Here are the limitations we must accept to get
faster reading:
Only formatted cell values are available, not underlying values or details on the formats.
We can't target a named range as the range
.
We have no access to the data type of a cell, i.e. we don't know that it's logical, numeric, or datetime. That must be re-discovered based on the CSV data (or specified by the user).
Auth and error handling have to be handled a bit differently internally, which may lead to behaviour that differs from other functions in googlesheets4.
Note that the Sheets API is still used to retrieve metadata on the target
Sheet, in order to support range specification. range_speedread()
also
sends an auth token with the request, unless a previous call to
gs4_deauth()
has put googlesheets4 into a de-authorized state.
range_speedread(ss, sheet = NULL, range = NULL, skip = 0, ...)
ss |
Something that identifies a Google Sheet:
Processed through |
sheet |
Sheet to read, in the sense of "worksheet" or "tab". You can identify a sheet by name, with a string, or by position, with a number. Ignored if the sheet is specified via |
range |
A cell range to read from. If |
skip |
Minimum number of rows to skip before reading anything, be it
column names or data. Leading empty rows are automatically skipped, so this
is a lower bound. Ignored if |
... |
Passed along to the CSV parsing function (currently
|
A tibble
if (require("readr")) {
# since cell type is not available, use readr's col type specification
range_speedread(
gs4_example("deaths"),
sheet = "other",
range = "A5:F15",
col_types = cols(
Age = col_integer(),
`Date of birth` = col_date("%m/%d/%Y"),
`Date of death` = col_date("%m/%d/%Y")
)
)
}
# write a Sheet that, by default, is NOT world-readable
(ss <- sheet_write(chickwts))
# demo that range_speedread() sends a token, which is why we can read this
range_speedread(ss)
# clean up
googledrive::drive_trash(ss)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.