Learn R Programming

readODS (version 1.8.0)

read_ods: Read Data From ODS File

Description

read_ods is a function to read a single sheet from an ods file and return a data frame. read.ods always returns a list of data frames with one data frame per sheet. This is a wrapper to read_ods for backward compatibility with previous version of readODS. Please use read_ods if possible.

Usage

read_ods(
  path,
  sheet = 1,
  col_names = TRUE,
  col_types = NULL,
  na = "",
  skip = 0,
  formula_as_formula = FALSE,
  range = NULL,
  row_names = FALSE,
  strings_as_factors = FALSE,
  check_names = FALSE,
  verbose = FALSE
)

read.ods(file = NULL, sheet = NULL, formulaAsFormula = FALSE)

Value

A data frame (data.frame) containing a representation of data in the ods file.

Arguments

path

path to the ods file.

sheet

sheet to read. Either a string (the sheet name), or an integer sheet number. The default is 1.

col_names

logical, indicating whether the file contains the names of the variables as its first line. Default is TRUE.

col_types

Either NULL to guess from the spreadsheet or refer to readr::type_convert() to specify cols specification. NA will return a data frame with all columns being "characters".

na

Character vector of strings to use for missing values. By default read_ods converts blank cells to missing data. It can also be set to NULL, so that empty cells are treated as NA.

skip

the number of lines of the data file to skip before beginning to read data. If this parameter is larger than the total number of lines in the ods file, an empty data frame is returned.

formula_as_formula

logical, a switch to display formulas as formulas "SUM(A1:A3)" or as the resulting value "3"... or "8".. . Default is FALSE.

range

selection of rectangle using Excel-like cell range, such as range = "D12:F15" or range = "R1C12:R6C15". Cell range processing is handled by the cellranger package.

row_names

logical, indicating whether the file contains the names of the rows as its first column. Default is FALSE.

strings_as_factors

logical, if character columns to be converted to factors. Default is FALSE.

check_names

logical, passed down to base::data.frame(). Default is FALSE.

verbose

logical, if messages should be displayed. Default is FALSE.

file

for read.ods only, path to the ods file.

formulaAsFormula

for read.ods only, a switch to display formulas as formulas "SUM(A1:A3)" or as the resulting value "3"... or "8"..

Author

Chung-hong Chan chainsawtiney@gmail.com, Gerrit-Jan Schutten phonixor@gmail.com

Examples

Run this code
if (FALSE) {
# Read a file
read_ods("starwars.ods")
# Read a specific sheet, e.g. the 2nd sheet
read_ods("starwars.ods", sheet = 2)
# Read a specific range, e.g. A1:C11
read_ods("starwars.ods", sheet = 2, range = "A1:C11")
}

Run the code above in your browser using DataLab