Skip to content

Commit

Permalink
compare colnames and not tables
Browse files Browse the repository at this point in the history
  • Loading branch information
agouy committed Aug 24, 2022
1 parent 3fe9576 commit 9c5e7de
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions main.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ assign("actual", 0, envir = .GlobalEnv)
task = ctx$task

headers <- ctx$op.value('Headers', as.logical, TRUE)
separator <- ctx$op.value('Separator', as.character, "Comma")
separator <- ctx$op.value('Separator', as.character, "Tab")
force_merge <- ctx$op.value('Force', as.logical, FALSE)

separator <- case_when(
TRUE ~ ",",
separator == "Comma" ~ ",",
separator == "Tab" ~ "\t"
)
Expand All @@ -58,7 +57,7 @@ csv_list <- f.names %>%
mutate(filename = rep_len(basename(filename), nrow(.)))
})

same_colnames <- all(sapply(csv_list, identical, csv_list[[1]]))
same_colnames <- all(sapply(csv_list, function(x) identical(colnames(x), colnames(csv_list[[1]]))))
if(!same_colnames & !force_merge) {
stop("All files must have strictly identical column names or the 'Force' option should be set to true.")
}
Expand Down

0 comments on commit 9c5e7de

Please sign in to comment.