Skip to content

Commit

Permalink
DS-4002 Handle uppercase SAV extension (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisfacer committed Oct 20, 2022
1 parent c2c5fd6 commit e57b172
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/mergingandstackingutilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ readDataSets <- function(data.set.names, min.data.sets = 1)
if (length(data.set.names) < min.data.sets)
stop("At least ", min.data.sets, " data set(s) are required.")

if (!all(grepl('.+\\.sav$', data.set.names))) {
if (!all(grepl('.+\\.sav$', data.set.names, ignore.case = TRUE))) {
stop("An input data file was not an SPSS .sav data file. ",
"Only SPSS .sav data files are accepted.")
}
Expand Down
Binary file added inst/testdata/cola2uppercase.SAV
Binary file not shown.
11 changes: 11 additions & 0 deletions tests/testthat/test-mergedatasetsbycase.R
Original file line number Diff line number Diff line change
Expand Up @@ -1254,5 +1254,16 @@ test_that("DS-3863: duplicate value labels", {
"50 to 54", "55 to 64", "65 or more")))
})

test_that("DS-4002: works when file extension in upper case", {
expect_error(merge.data.set.output <- MergeDataSetsByCase(data.set.names = c(findInstDirFile("cola1.sav"),
findInstDirFile("cola2uppercase.SAV"),
findInstDirFile("cola5.sav"),
findInstDirFile("cola8.sav")),
data.sets.whose.variables.are.kept = 1,
variables.to.combine = "Q4_A_3,Q4_A_3_new",
auto.select.what.to.match.by = FALSE,
match.by.variable.labels = FALSE), NA)
})

if (file.exists("Combined data set.sav"))
file.remove("Combined data set.sav")

0 comments on commit e57b172

Please sign in to comment.