RData.jl icon indicating copy to clipboard operation
RData.jl copied to clipboard

R data file with non-standard extension is recognized as generic GZip file.

Open matbesancon opened this issue 6 years ago • 5 comments

MWE:

]add RData

import RData
RData.load("dat.Rda")

Error encountered while loading "path_to_dat.Rda".
Fatal error:
ERROR: ArgumentError: Package Libz not found in current path:
- Run `import Pkg; Pkg.add("Libz")` to install the Libz package.

matbesancon avatar Apr 01 '19 14:04 matbesancon

I cannot reproduce it. Also, AFAIK Libz is not used, RData uses CodecZlib instread. If you still have the issue, could you please show the full output of your Julia session?

alyst avatar Apr 02 '19 13:04 alyst

Sure:

~ ⌚ 16:38:35
$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.1.0 (2019-01-21)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(v1.1) pkg> add RData
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...
  Updating `~/.julia/environments/v1.1/Project.toml`
  [df47a6cb] + RData v0.6.0
  Updating `~/.julia/environments/v1.1/Manifest.toml`
  [8f5d6c58] + EzXML v0.9.1
  [5789e2e9] + FileIO v1.0.6
  [60bf3e95] + GLPK v0.9.1
  [78c3b35d] + Mocking v0.5.7
  [df47a6cb] + RData v0.6.0
  [f269a46b] + TimeZones v0.9.0

julia> import RData

julia> RData.load("numerics/data/data/data_n100_m100_p50_q50_r50_s100_sc1_case53.Rda")
Error encountered while loading "numerics/data/data/data_n100_m100_p50_q50_r50_s100_sc1_case53.Rda".
Fatal error:
ERROR: ArgumentError: Package Libz not found in current path:
- Run `import Pkg; Pkg.add("Libz")` to install the Libz package.

To be complete, the data come from this repo

matbesancon avatar Apr 02 '19 14:04 matbesancon

Thanks! Now I can reproduce it. The problem is that .Rda extension (case sensitive) is not registered in FileIO package, so RData.load() (which is just reexported FileIO.load()) tries to detect the file type by looking at its first bytes. Since GZIP format is checked before RData, FileIO recognizes the file as gzipped and tries to use Libz. Probably this should be fixed on FileIO side, I'll write the bug report.

Meanwhile you can rename your files into ".rda", ".RData" or ".rdata" as a workaround.

alyst avatar Apr 02 '19 15:04 alyst

good catch thanks!

matbesancon avatar Apr 02 '19 15:04 matbesancon

This should be fixed in FileIO 1.6.1.

timholy avatar Mar 07 '21 09:03 timholy