Skip to contents

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,
  whitespace = 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.

whitespace

Whether to process multiple whitespaces.

Value

A tibble, presenting cells in a traditional two-dimension spreadsheet format.

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)
#>  Extracting XML
#>  Extracting XML [9ms]
#> 
#>  Getting sheet
#>  Getting sheet [16ms]
#> 
#>  Extracting cell and row info
#>  Extracting cell and row info [62ms]
#> 
#>  Generating output table
#>  Generating output table [74ms]
#> 
#>  Rectifying cells to sheet layout
#>  Rectifying cells to sheet layout [34ms]
#> 
#> # 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")