harphub / harpIO

IO functions for HARP
https://harphub.github.io/harpIO/
Other
6 stars 16 forks source link

vobs to sqlite fails after recent commit #14

Closed mpartio closed 4 years ago

mpartio commented 4 years ago

After 2954e0e9c43bf05e09b26728c69ab5ba0d9e7368 vobs to sqlite (read_obs_convert.R) does not produce any output files.

I narrowed the problem to read_vobs():

read_vobs <- function(file_name, missing_value = -99, ...) {

  empty_data <- empty_data_interpolate(NA, NA, empty_type = "obs")

  if (file.exists(file_name)) {
    message("Reading: ", file_name)
  } else {
    warning("File not found: ", file_name, call. = FALSE, immediate. = TRUE)
    return(list(synop = empty_data, temp = empty_data))
  }

  v_data <- read_vfile(file_name, v_type = "vobs")
  if (is.null(v_data)) {
    return(list(synop = empty_data, temp = empty_data))
  }

}

There is no explict return statement, so the value of last evaluated statement is returned which in this case is the if statement.

I fixed the issue in my fork: https://github.com/mpartio/harpIO/commit/a3443d36b0d61ece8c42152dae040a6cd91e11d0

andrew-MET commented 4 years ago

fixed: https://github.com/andrew-MET/harpIO/commit/45a14c49a90d0deee8ae9673b7c0d8e671aa5b1d