Failed to precompile CSV due to load error

Hi, I am trying to read a CSV file to a dataframe.
Every time I try to use the CSV.jl package to read csv file. I am greeted with the following error:
LoadError: Failed to precompile CSV [336ed68f-0bac-5ca0-87d4-7b16caf5d00b]

I have tried: updating, resolving, removing and adding back the package and all results in the same error.
I considered using DelimitedFiles.jl but I am unable to use the first row as header as it imports as a matrix. Which is why I am trying to use CVS.jl paackage.

Full details of the error below:
ERROR: LoadError: Failed to precompile CSV [336ed68f-0bac-5ca0-87d4-7b16caf5d00b] to C:\Users\ohian.julia\compiled\v1.6\CSV\jl_A93C.tmp.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::Base.TTY, internal_stdout::Base.TTY, ignore_loaded_modules::Bool)
@ Base .\loading.jl:1385
[3] compilecache(pkg::Base.PkgId, path::String)
@ Base .\loading.jl:1329
[4] _require(pkg::Base.PkgId)
@ Base .\loading.jl:1043
[5] require(uuidkey::Base.PkgId)
@ Base .\loading.jl:936
[6] require(into::Module, mod::Symbol)
@ Base .\loading.jl:923
[7] eval
@ .\boot.jl:360 [inlined]
[8] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base .\loading.jl:1116
[9] invokelatest(::Any, ::Any, ::Vararg{Any, N} where N; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Base .\essentials.jl:708
[10] invokelatest(::Any, ::Any, ::Vararg{Any, N} where N)
@ Base .\essentials.jl:706
[11] inlineeval(m::Module, code::String, code_line::Int32, code_column::Int32, file::String; softscope::Bool)
@ VSCodeServer c:\Users\ohian.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\eval.jl:207
[12] (::VSCodeServer.var"#58#62"{Bool, Bool, Module, String, Int32, Int32, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer c:\Users\ohian.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\eval.jl:153
[13] withpath(f::VSCodeServer.var"#58#62"{Bool, Bool, Module, String, Int32, Int32, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
@ VSCodeServer c:\Users\ohian.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\repl.jl:185
[14] (::VSCodeServer.var"#57#61"{Bool, Bool, Bool, Module, String, Int32, Int32, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer c:\Users\ohian.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\eval.jl:151
[15] hideprompt(f::VSCodeServer.var"#57#61"{Bool, Bool, Bool, Module, String, Int32, Int32, String, VSCodeServer.ReplRunCodeRequestParams})
@ VSCodeServer c:\Users\ohian.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\repl.jl:36
[16] (::VSCodeServer.var"#56#60"{Bool, Bool, Bool, Module, String, Int32, Int32, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer c:\Users\ohian.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\eval.jl:122
[17] with_logstate(f::Function, logstate::Any)
@ Base.CoreLogging .\logging.jl:491
[18] with_logger
@ .\logging.jl:603 [inlined]
[19] (::VSCodeServer.var"#55#59"{VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer c:\Users\ohian.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\eval.jl:197
[20] #invokelatest#2
@ .\essentials.jl:708 [inlined]
[21] invokelatest(::Any)
@ Base .\essentials.jl:706
[22] macro expansion
@ c:\Users\ohian.vscode\extensions\julialang.language-julia-1.4.3\scripts\packages\VSCodeServer\src\eval.jl:34 [inlined]
[23] (::VSCodeServer.var"#53#54")()
@ VSCodeServer .\task.jl:411

1 Like

What package versions are you on?

For DelimitedFiles you could just do something like:

data = readdlm("myfile.csv")

df = DataFrame(data[2:end, :], string.(data[1, :]))

although some additional type inference might be required as postprocessing.

1 Like

Thank you! This worked
I ended up with:

data = (readdlm("myfile.csv", ',' ))
df= DataFrame([[data[2:end,i]...] for i in 1:size(data,2)], Symbol.(data[1,:]))

Also: I was using the version of CSV I am using was v0.9.8.

I also later found that broadcasting the identity function over the data-frame variable did the trick

data, header = readdlm("myfile.csv", ',', header= true);
df=  DataFrame(data, vec(header));
df_new = identity.( DataFrame(data, vec(header)))