Skip to content

Commit

Permalink
more wb_to_df() to snake_case
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMarvin committed Jul 7, 2023
1 parent 1880941 commit 5a702d3
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 115 deletions.
138 changes: 69 additions & 69 deletions R/readWorkbook.R
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
#' @name read_xlsx
#' @title Read from an Excel file or Workbook object
#' @description Read data from an Excel file or Workbook object into a data.frame
#' @param xlsxFile An xlsx file, Workbook object or URL to xlsx file.
#' @param xlsx_file An xlsx file, Workbook object or URL to xlsx file.
#' @param sheet The name or index of the sheet to read data from.
#' @param startRow first row to begin looking for data.
#' @param startCol first column to begin looking for data.
#' @param colNames If `TRUE`, the first row of data will be used as column names.
#' @param skipEmptyRows If `TRUE`, empty rows are skipped else empty rows after the first row containing data
#' @param start_row first row to begin looking for data.
#' @param start_col first column to begin looking for data.
#' @param col_names If `TRUE`, the first row of data will be used as column names.
#' @param skip_empty_rows If `TRUE`, empty rows are skipped else empty rows after the first row containing data
#' will return a row of NAs.
#' @param rowNames If `TRUE`, first column of data will be used as row names.
#' @param detectDates If `TRUE`, attempt to recognize dates and perform conversion.
#' @param row_names If `TRUE`, first column of data will be used as row names.
#' @param detect_dates If `TRUE`, attempt to recognize dates and perform conversion.
#' @param cols A numeric vector specifying which columns in the Excel file to read.
#' If NULL, all columns are read.
#' @param rows A numeric vector specifying which rows in the Excel file to read.
#' If NULL, all rows are read.
#' @param check.names logical. If TRUE then the names of the variables in the data frame
#' are checked to ensure that they are syntactically valid variable names
#' @param sep.names (unimplemented) One character which substitutes blanks in column names. By default, "."
#' @param namedRegion A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored.
#' @param named_region A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored.
#' @param na.strings A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA.
#' @param na.numbers A numeric vector of digits which are to be interpreted as NA. Blank cells will be returned as NA.
#' @param fillMergedCells If TRUE, the value in a merged cell is given to all cells within the merge.
#' @param skipEmptyCols If `TRUE`, empty columns are skipped.
#' @param fill_merged_cells If TRUE, the value in a merged cell is given to all cells within the merge.
#' @param skip_empty_cols If `TRUE`, empty columns are skipped.
#' @param ... additional arguments passed to `wb_to_df()`
#' @seealso [wb_get_named_regions()] [wb_to_df()]
#' @details Formulae written using write_formula to a Workbook object will not get picked up by read_xlsx().
Expand All @@ -34,23 +34,23 @@
#' read_xlsx(xlsxFile = xlsxFile)
#' @export
read_xlsx <- function(
xlsxFile,
xlsx_file,
sheet,
startRow = 1,
startCol = NULL,
rowNames = FALSE,
colNames = TRUE,
skipEmptyRows = FALSE,
skipEmptyCols = FALSE,
rows = NULL,
cols = NULL,
detectDates = TRUE,
namedRegion,
na.strings = "#N/A",
na.numbers = NA,
check.names = FALSE,
sep.names = ".",
fillMergedCells = FALSE,
start_row = 1,
start_col = NULL,
row_names = FALSE,
col_names = TRUE,
skip_empty_rows = FALSE,
skip_empty_cols = FALSE,
rows = NULL,
cols = NULL,
detect_dates = TRUE,
named_region,
na.strings = "#N/A",
na.numbers = NA,
check.names = FALSE,
sep.names = ".",
fill_merged_cells = FALSE,
...
) {

Expand All @@ -60,21 +60,21 @@ read_xlsx <- function(
sheet <- substitute()

wb_to_df(
xlsxFile,
sheet = sheet,
startRow = startRow,
startCol = startCol,
rowNames = rowNames,
colNames = colNames,
skipEmptyRows = skipEmptyRows,
skipEmptyCols = skipEmptyCols,
rows = rows,
cols = cols,
detectDates = detectDates,
named_region = namedRegion,
na.strings = na.strings,
na.numbers = na.numbers,
fillMergedCells = fillMergedCells,
xlsx_file,
sheet = sheet,
start_row = start_row,
start_col = start_col,
row_names = row_names,
col_names = col_names,
skip_empty_rows = skip_empty_rows,
skip_empty_cols = skip_empty_cols,
rows = rows,
cols = cols,
detect_dates = detect_dates,
named_region = named_region,
na.strings = na.strings,
na.numbers = na.numbers,
fill_merged_cells = fill_merged_cells,
...
)
}
Expand All @@ -96,20 +96,20 @@ read_xlsx <- function(
#' xlsxFile <- system.file("extdata", "openxlsx2_example.xlsx", package = "openxlsx2")
#' df1 <- wb_read(xlsxFile = xlsxFile, sheet = 1, rows = c(1, 3, 5), cols = 1:3)
wb_read <- function(
xlsxFile,
sheet = 1,
startRow = 1,
startCol = NULL,
rowNames = FALSE,
colNames = TRUE,
skipEmptyRows = FALSE,
skipEmptyCols = FALSE,
rows = NULL,
cols = NULL,
detectDates = TRUE,
namedRegion,
na.strings = "NA",
na.numbers = NA,
xlsx_file,
sheet = 1,
start_row = 1,
start_col = NULL,
row_names = FALSE,
col_names = TRUE,
skip_empty_rows = FALSE,
skip_empty_cols = FALSE,
rows = NULL,
cols = NULL,
detect_dates = TRUE,
named_region,
na.strings = "NA",
na.numbers = NA,
...
) {

Expand All @@ -119,20 +119,20 @@ wb_read <- function(
sheet <- substitute()

wb_to_df(
xlsxFile = xlsxFile,
sheet = sheet,
startRow = startRow,
startCol = startCol,
rowNames = rowNames,
colNames = colNames,
skipEmptyRows = skipEmptyRows,
skipEmptyCols = skipEmptyCols,
rows = rows,
cols = cols,
detectDates = detectDates,
named_region = namedRegion,
na.strings = na.strings,
na.numbers = na.numbers,
xlsx_file = xlsx_file,
sheet = sheet,
start_row = start_row,
start_col = start_col,
row_names = row_names,
col_names = col_names,
skip_empty_rows = skip_empty_rows,
skip_empty_cols = skip_empty_cols,
rows = rows,
cols = cols,
detect_dates = detect_dates,
named_region = named_region,
na.strings = na.strings,
na.numbers = na.numbers,
...
)

Expand Down
16 changes: 8 additions & 8 deletions R/wb_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -683,14 +683,14 @@ wb_to_df <- function(
# TODO there probably is a better way in not reducing cc above, so
# that we do not have to go through large xlsx files multiple times
z_fill <- wb_to_df(
xlsxFile = wb,
sheet = sheet,
dims = filler,
na.strings = na.strings,
convert = FALSE,
colNames = FALSE,
detectDates = detect_dates,
showFormula = show_formula,
xlsx_file = wb,
sheet = sheet,
dims = filler,
na.strings = na.strings,
convert = FALSE,
col_names = FALSE,
detect_dates = detect_dates,
show_formula = show_formula,
keep_attributes = TRUE
)

Expand Down
40 changes: 20 additions & 20 deletions man/read_xlsx.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 18 additions & 18 deletions man/wb_read.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5a702d3

Please sign in to comment.