JuliaIO/FileIO.jl

Facing issue reading new file format

shubhank-saxena opened this issue · 5 comments

I am working on a new package which reads the .las well logging files in Julia and try to extract information. I have done the following steps to use everything -

  • I have added add_format(format"LAS", (), [".las"], [:WellIO]) in the registry.jl of the FileIO(on my fork, not raised a PR as of now)
  • I installed the dependency FileIO for my package from my copy of FileIO
(WellIO) pkg> add https://github.com/shubhank-saxena/FileIO.jl
  • I loaded my new package in the REPL using -
julia> using WellIO
[ Info: Precompiling WellIO [e3a1248c-9b61-463c-be64-bcf50051af9a]
  • Now as soon as I try to load up file it's throwing error
julia> WellIO.load("./Bean_A.las")
ERROR: MethodError: no method matching load(::String)
Closest candidates are:
  load(::FileIO.File{FileIO.DataFormat{:LAS}}) at /home/shubhank/Documents/Julia/WellIO.jl/src/WellIO.jl:6
Stacktrace:
 [1] top-level scope at REPL[10]:1

This is my module package code -

module WellIO

using FileIO
using Tables

function load(file::File{format"LAS"})
    dat = open(file) do f
            read(f,string)
    end
    print(dat)    
end

end

I am not able to figure out the error of why FileIO is not able to parse the file!

Try FileIO.load("./Bean_A.las")

Try FileIO.load("./Bean_A.las")

Getting the error

julia> using FileIO

julia> FileIO.load("./Bean_A.las")
Error encountered while loading "./Bean_A.las".

Fatal error:
ERROR: MethodError: no method matching read(::IOStream, ::typeof(string))
Closest candidates are:
  read(::IOStream) at iostream.jl:488
  read(::IOStream, ::Type{UInt8}) at iostream.jl:383
  read(::IOStream, ::Union{Type{Int16}, Type{Int32}, Type{Int64}, Type{UInt16}, Type{UInt32}, Type{UInt64}}) at iostream.jl:392
  ...
Stacktrace:
 [1] handle_error(::MethodError, ::File{DataFormat{:LAS}}) at /home/shubhank/.julia/packages/FileIO/vZjlh/src/error_handling.jl:82
 [2] handle_exceptions(::Array{Any,1}, ::String) at /home/shubhank/.julia/packages/FileIO/vZjlh/src/error_handling.jl:77
 [3] load(::Formatted; options::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/shubhank/.julia/packages/FileIO/vZjlh/src/loadsave.jl:210
 [4] load at /home/shubhank/.julia/packages/FileIO/vZjlh/src/loadsave.jl:187 [inlined]
 [5] #load#16 at /home/shubhank/.julia/packages/FileIO/vZjlh/src/loadsave.jl:136 [inlined]
 [6] load(::String) at /home/shubhank/.julia/packages/FileIO/vZjlh/src/loadsave.jl:136
 [7] top-level scope at REPL[4]:1

That's likely now an error in your integration ;)
Admittedly the stacktrace is horrible...
You should also be able to run file = FileIO.query("./Bean_A.las") to see if the recognition part works... and once that works, you can try WellIO.load(file) to get better errors

That's likely now an error in your integration ;)
Admittedly the stacktrace is horrible...
You should also be able to run file = FileIO.query("./Bean_A.las") to see if the recognition part works... and once that works, you can try WellIO.load(file) to get better errors

This works!! I am able to see my file! Thank you

Nothing to do here it seems, closing.