R/read_sheet_then_save_csv.R
read_sheet_then_save_csv.Rd
read_sheet_then_save_csv()
is heavily inspired in readxl::read_excel()
(actually, this inherit almost all argument from it).
read_sheet_then_save_csv(
excel_sheet,
path_to_xlsx,
dir_to_save = NULL,
range = NULL,
col_types = NULL,
col_names = TRUE,
na = "",
trim_ws = TRUE,
skip = 0,
n_max = Inf,
guess_max = min(1000, n_max),
.name_repair = "unique"
)
a character vector with the name of the excel sheet
a character vector with the path of the excel file
a character vector with the path to save the csv file. Default is NULL and save the csv in the "data/temp" if it exists.
A cell range to read from. Includes typical Excel ranges like "B3:D87".
Either NULL to guess all from the spreadsheet or a character vector containing one entry per column from these options: "skip", "guess", "logical", "numeric", "date", "text" or "list". If exactly one col_type is specified, it will be recycled.
TRUE to use the first row as column names
Character vector of strings to interpret as missing values. By default, treats blank cells as missing data.
Should leading and trailing whitespace be trimmed?
Minimum number of rows to skip before reading anything, be it column names or data.
Maximum number of data rows to read.
Maximum number of data rows to use for guessing column types.
Handling of column names
read_sheet_then_save_csv()
is an adaptation of the awesome workflow described
in an article
from {readxl}
package site.
if (FALSE) {
# read and into a csv
misc::create_dirs("ma-box")
xlsx_file <-
system.file("xlsx-examples", "mtcars_workbook_001.xlsx", package = "misc")
read_sheet_then_save_csv(
excel_sheet = "mtcars_sheet_001",
path_to_xlsx = xlsx_file,
dir_to_save = "ma-box"
)
}