diff --git a/NEWS.md b/NEWS.md index f2a39f7..8c580c6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# Changes in version 1.0.9 (release date:15-07-2026) + +- Fix bug in readActiwatchCount. #92 + # Changes in version 1.0.8 (release date:11-03-2026) - Update readActiwatchCount to handle behaviour upcoming data.table package release. #89 diff --git a/R/readActiwatchCount.R b/R/readActiwatchCount.R index 284bde3..dcaa385 100644 --- a/R/readActiwatchCount.R +++ b/R/readActiwatchCount.R @@ -54,10 +54,9 @@ readActiwatchCount = function(filename = NULL, #========================================================= # ! Assumption that first data row equals the first row with 3 columns index = 0 - quote = detectQuote(filename = filename, skip = 50) - NC = 1 - while (NC >= 3) { + NC = 0 + while (NC < 3) { testraw = data.table::fread(input = filename, header = FALSE, sep = ",", skip = index, nrows = 1, data.table = TRUE, quote = quote) @@ -67,6 +66,7 @@ readActiwatchCount = function(filename = NULL, } else { index = index + 1 } + if (nrow(testraw) == 0) stop("No data in file") } D = data.table::fread(input = filename, sep = ",", skip = index, quote = quote, data.table = FALSE) diff --git a/tests/testthat/test_readActiwatchCount.R b/tests/testthat/test_readActiwatchCount.R index 5bf240c..86ae4e1 100644 --- a/tests/testthat/test_readActiwatchCount.R +++ b/tests/testthat/test_readActiwatchCount.R @@ -14,9 +14,8 @@ test_that("Actiwatch csv is correctly read", { }) test_that("Actiwatch awd is correctly read", { file = system.file("testfiles/Actiwatch.AWD", package = "GGIRread") - expect_warning(D <- readActiwatchCount(filename = file, timeformat = "%d-%b-%Y %H:%M:%S", - desiredtz = "Europe/Amsterdam"), - regexp = "Detected 1 column names but the data has 3 columns*") + D <- readActiwatchCount(filename = file, timeformat = "%d-%b-%Y %H:%M:%S", + desiredtz = "Europe/Amsterdam") expect_equal(D$epochSize, 60) expect_equal(format(D$startTime), "2009-10-01 17:00:00") expect_equal(nrow(D$data), 329) @@ -28,9 +27,8 @@ test_that("Actiwatch awd is correctly read", { test_that("Actiwatch awd error correctly", { file = system.file("testfiles/Actiwatch.AWD", package = "GGIRread") - expect_error(expect_warning(readActiwatchCount(filename = file, + expect_error(readActiwatchCount(filename = file, timeformat = "%d-%m-%Y %H:%M:%S"), - regexp = "Detected 1 column names but the data has 3 columns*"), regexp = "Time format*") expect_error(readActiwatchCount(filename = "",