Skip to content

Commit

Permalink
fix: hydro-imgw
Browse files Browse the repository at this point in the history
  • Loading branch information
bczernecki committed Oct 20, 2024
1 parent d114c26 commit 572811a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions R/hydro_imgw_annual.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ hydro_imgw_annual_bp = function(year = year,
file1 = paste(temp2, dir(temp2), sep = "/")[1]

if (translit) {
data1 = as.data.frame(data.table::fread(cmd = paste("iconv -f CP1250 -t ASCII//TRANSLIT", file1)))
data1 = as.data.frame(data.table::fread(cmd = paste("iconv -f ISO-8859-2 -t ASCII//TRANSLIT", file1)))
} else {
data1 = read.csv(file1, header = FALSE, stringsAsFactors = FALSE, fileEncoding = "CP1250")
data1 = tryCatch(expr = read.csv(file1, header = FALSE, stringsAsFactors = FALSE, sep = ",",
fileEncoding = "CP1250"),
warning = function(w) {
read.csv(file1, header = FALSE, stringsAsFactors = FALSE, sep = ";")
})

Check warning on line 102 in R/hydro_imgw_annual.R

View check run for this annotation

Codecov / codecov/patch

R/hydro_imgw_annual.R#L98-L102

Added lines #L98 - L102 were not covered by tests
}

colnames(data1) = meta[[value]]$parameters
Expand Down
10 changes: 7 additions & 3 deletions R/hydro_imgw_monthly.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ hydro_imgw_monthly_bp = function(year,
meta = hydro_metadata_imgw(interval)

all_data = vector("list", length = length(catalogs))

for (i in seq_along(catalogs)) {
catalog = catalogs[i]

adres = paste0(base_url, interval_pl, "/", catalog, "/mies_", catalog, ".zip")

temp = tempfile()
Expand All @@ -87,9 +87,13 @@ hydro_imgw_monthly_bp = function(year,
file1 = paste(temp2, dir(temp2), sep = "/")[1]

if (translit) {
data1 = as.data.frame(data.table::fread(cmd = paste("iconv -f CP1250 -t ASCII//TRANSLIT", file1)))
data1 = as.data.frame(data.table::fread(cmd = paste("iconv -f ISO-8859-2 -t ASCII//TRANSLIT", file1)))
} else {
data1 = read.csv(file1, header = FALSE, stringsAsFactors = FALSE, fileEncoding = "CP1250")
data1 = tryCatch(expr = read.csv(file1, header = FALSE, stringsAsFactors = FALSE, sep = ",",
fileEncoding = "CP1250"),
warning = function(w) {
read.csv(file1, header = FALSE, stringsAsFactors = FALSE, sep = ";")
})

Check warning on line 96 in R/hydro_imgw_monthly.R

View check run for this annotation

Codecov / codecov/patch

R/hydro_imgw_monthly.R#L92-L96

Added lines #L92 - L96 were not covered by tests
}

colnames(data1) = meta[[1]][, 1]
Expand Down

0 comments on commit 572811a

Please sign in to comment.