Commit eb447e35 authored by bob's avatar bob
Browse files

Add error message for empty columns in input file

If any column is empty script with now halt with a proper error message.
No more empty workbook will be produced.
parent 85f7cff8
......@@ -165,15 +165,21 @@ read_data_sheet <- function(file, sheet) {
process_sheet <- function(file, sheet) {
dat <- read_data_sheet(file, sheet)
## From the first row of the file, extract...
header <- strsplit(as.character(dat[1, ]), "\\$")
empty_columns <- vapply(header, length, FUN.VALUE = integer(1)) == 0
if (any(empty_columns)) {
stop(sprintf("Empty column name in %s", basename(file$path)),
call. = FALSE)
}
# From header extract...
variables <- vapply(header, `[`, 1, FUN.VALUE = character(1)) # variable names
units <- vapply(header, `[`, 2, FUN.VALUE = character(1)) # units
## Assign variable names as column names
# Assign variable names as column names
names(dat) <- variables
# and delete the first row
# and delete the first row (== header)
dat <- dat[-1, ]
processed_sheet <- list(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment