brry / rdwd

download climate data from DWD (German Weather Service)
https://bookdown.org/brry/rdwd
72 stars 13 forks source link

Error when 'fread = TRUE' #1

Closed fdetsch closed 6 years ago

fdetsch commented 6 years ago

In the below example, the standard data import works as expected

lnk = selectDWD(id = 3379, res = "hourly", var = "air_temperature", per = "r")
dat1 = dataDWD(lnk, dir = file.path(tempdir(), "DWDdata")) # works

whereas fast reading using fread = TRUE fails

dat2 = dataDWD(lnk, dir = file.path(tempdir(), "DWDdata"), fread = TRUE) # error

with the following error message

Error in data.table::fread(paste("unzip -p", file, fp), na.strings = na9(), : freadMain: NAstring << -9999>> has whitespace at the beginning or end

Here's my sessionInfo():

R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252    LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C                    LC_TIME=German_Germany.1252    

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] mapview_2.4.8 rdwd_0.10.2   DWD_0.1.0     sf_0.6-3     

loaded via a namespace (and not attached):
 [1] xfun_0.3              pbapply_1.3-4         lattice_0.20-35       colorspace_1.3-2      htmltools_0.3.6      
 [6] stats4_3.5.1          viridisLite_0.3.0     yaml_2.1.19           base64enc_0.1-3       e1071_1.6-8          
[11] later_0.7.3           withr_2.1.2           DBI_1.0.0             sp_1.3-1              RColorBrewer_1.1-2   
[16] plyr_1.8.4            munsell_0.5.0         raster_2.6-7          htmlwidgets_1.2       devtools_1.13.6      
[21] memoise_1.1.0         latticeExtra_0.6-28   knitr_1.20            httpuv_1.4.4.2        crosstalk_1.0.0      
[26] class_7.3-14          Rcpp_0.12.17          xtable_1.8-2          promises_1.0.1        scales_0.5.0         
[31] classInt_0.2-3        satellite_1.0.1       plotrix_3.7-2         leaflet_2.0.1         webshot_0.5.0        
[36] jsonlite_1.5          abind_1.4-5           mime_0.5              png_0.1-7             digest_0.6.15        
[41] Orcs_1.0.0            bookdown_0.7          shiny_1.1.0           berryFunctions_1.17.0 grid_3.5.1           
[46] RPostgreSQL_0.6-2     rgdal_1.3-3           tools_3.5.1           bitops_1.0-6          magrittr_1.5         
[51] RCurl_1.95-4.11       data.table_1.11.4     spData_0.2.9.0        R6_2.2.2              units_0.6-0          
[56] compiler_3.5.1 
brry commented 6 years ago

Thanks for pointing this out - seems like this was already changed in fread in April. The fix is on its way to github. https://github.com/Rdatatable/data.table/commit/e64b952a4a1576a2a5956176af8f5077f36cb0d9#diff-537009978509c34a2382eec1cb263c70