Skip to content

Commit

Permalink
Merge pull request #2 from nationalparkservice/bug-fix
Browse files Browse the repository at this point in the history
Fix issue where file doesn't read if there is only one Date column
  • Loading branch information
wright13 authored May 22, 2024
2 parents 551f579 + e556b5b commit 54d7ea4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.RData
.Ruserdata
docs
*.xlsx
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ Imports:
tidyr,
tidyxl
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
RoxygenNote: 7.3.1
URL: https://nationalparkservice.github.io/imd-ccal/
2 changes: 1 addition & 1 deletion R/read_write.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ getCCALData <- function(files) {
# Extract chem results
data <- suppressMessages(readxl::read_excel(file, sheet = 2, skip = 3, col_names = TRUE))
first_chem_col <- max(grep("delivery\\s*date", names(data), ignore.case = TRUE), grep("date\\s*filtered", names(data), ignore.case = TRUE)) + 1 # Get index of first chem data column
last_date_col <- max(grep("^date\\.\\.\\.\\d+$", names(data), ignore.case = TRUE))
last_date_col <- max(grep("^date(\\.\\.\\.\\d+){0,1}$", names(data), ignore.case = TRUE))
names(data) <- trimws(names(data))
data <- data %>%
tidyr::pivot_longer(first_chem_col:last_date_col, names_to = "param") %>%
Expand Down

0 comments on commit 54d7ea4

Please sign in to comment.