A wrapper around read_ods_cells()
and one of the
rectify functions provided in the package.
Usage
read_ods_sheet(
path,
sheet = 1,
rectify = c("simple", "smart"),
skip = 0,
col_headers = TRUE,
base_values = TRUE,
quick = FALSE,
quiet = FALSE
)
Arguments
- path
The ODS file
- sheet
The sheet within the ODS file
- rectify
The method to convert cells to two-dimensions, either "simple" or "smart (see details).
- skip
The number of rows to skip before attempting to rectify the cells.
- col_headers
Whether to use the first row (after any skipping) as the column header (
TRUE
is the default), alternatively a character vector of column names can be provided.- base_values
Whether to use the base_value of a cell (TRUE, the default) or whether to provide the cell content as seen by a spreadsheet user.
- quick
Whether to use the quick reading process.
- quiet
Whether to silence console messages (recommended for bulk processing)
Details
When rectify = "simple"
then the simple_rectify()
function will be used
to coerce the cells to a sheet. You can instruct the rectifier to skip rows,
whether to use the first row as column headers (or provide your own), and
whether to use the underlying values or the formatted cell content for the
value of the output cell. If quick = TRUE
this implies using the cell
content, thus the user setting for base_values
is ignored and treated as if
set to FALSE
.
When rectify = "smart"
then the smart_rectify()
function will be used,
this will attempt to guess the location of the column headers as well as
coercing the columns using value type information extracted from the ODS.
Using the smart rectifier ignores any settings for base_values
, skip
and
col_headers
. You cannot set quick = TRUE
if you want to use the
smart rectifier.
Examples
example <- system.file("extdata", "basic_example.ods", package = "tidyods")
read_ods_sheet(example, 1)
#> # A tibble: 6 × 4
#> species female bill_length_mm body_mass_g
#> <chr> <chr> <chr> <chr>
#> 1 Adelie false 40.3904109589041 4043.49315068493
#> 2 Adelie true 37.2575342465753 3368.83561643836
#> 3 Chinstrap false 51.0941176470588 3938.97058823529
#> 4 Chinstrap true 46.5735294117647 3527.20588235294
#> 5 Gentoo false 49.4737704918033 5484.83606557377
#> 6 Gentoo true 45.5637931034483 4679.74137931035
read_ods_sheet(example, 2, "smart")
#> # A tibble: 15 × 10
#> String Boolean Currency Date Time DateTime
#> <chr> <lgl> <dbl> <dttm> <time> <dttm>
#> 1 "Cell" TRUE 1.2 2022-06-15 00:00:00 13:24:56 2022-06-15 13:24:56
#> 2 "Cell with… FALSE 1.2 2022-06-15 00:00:00 13:24:56 2022-06-15 13:24:56
#> 3 "Cell with… TRUE 1.2 2022-06-15 00:00:00 13:24:56 2022-06-15 13:24:56
#> 4 "Cell wit… TRUE 1.2 2022-06-15 00:00:00 13:24:56 2022-06-15 13:24:56
#> 5 "Cells wi… FALSE 1.2 2022-06-15 00:00:00 13:24:56 2022-06-15 13:24:56
#> 6 "Cell with… FALSE 1.2 2022-06-15 00:00:00 13:24:56 2022-06-15 13:24:56
#> 7 "Merged ce… TRUE 1.2 2022-06-15 00:00:00 13:24:56 2022-06-15 13:24:56
#> 8 NA FALSE 1.2 2022-06-15 00:00:00 13:24:56 2022-06-15 13:24:56
#> 9 "Merged ce… FALSE 1.2 2022-06-15 00:00:00 13:24:56 2022-06-15 13:24:56
#> 10 "Hidden te… TRUE 1.2 2022-06-15 00:00:00 13:24:56 2022-06-15 13:24:56
#> 11 "Cell with… FALSE 1.2 2022-06-15 00:00:00 13:24:56 2022-06-15 13:24:56
#> 12 "Repeated … TRUE 1.2 2022-06-15 00:00:00 13:24:56 2022-06-15 13:24:56
#> 13 "Repeated … TRUE 1.2 2022-06-15 00:00:00 13:24:56 2022-06-15 13:24:56
#> 14 "Repeated … TRUE 1.2 2022-06-15 00:00:00 13:24:56 2022-06-15 13:24:56
#> 15 "une cellu… NA NA NA NA NA
#> # ℹ 4 more variables: Float <dbl>, Percentage <dbl>, Formula <dbl>,
#> # Errors <chr>