Writeshortest error

I keep getting this error as below, after I upgraded my DIVAnd.jl package. Not sure if they are realted, but I was able to run scripts like CSV.write without any issues even yesterday.

“UndefVarError: writeshortest not defined”.

Does anyone know how to fix this issue? Many thanks.

It’s a version mismatch between Parsers + CSV; it shouldn’t be possible to get those versions out of sync, but sometimes it happens. Probably just need to update Parsers.

1 Like

Many thanks. How do I update Parsers? I just did the below and the error remains.

using Pkg
Pkg.add("Parsers")

] up Parsers. You need to make sure you get a Parsers.jl version that is >= 2.5.

Just did as you recommended. I checked the version as well, v2.5.2. Unfortunately, it still produces the same error as below:

LoadError: UndefVarError: writeshortest not defined

Hmmmm, where is the error coming from exactly? (what’s the full error backtrace?) Maybe it’s CSV.jl that needs to be updated.

My CSV is up to date, version 0.10.4.

Below is my full error backtrace:

ERROR: LoadError: UndefVarError: writeshortest not defined
Stacktrace:
  [1] writecell(buf::Vector{UInt8}, pos::Int64, len::Int64, io::IOStream, x::Float64, opts::CSV.Options{UInt8, UInt8, Nothing, Tuple{}, typeof(CSV._identity)})
    @ CSV ~/.julia/packages/CSV/jFiCn/src/write.jl:444
  [2] (::CSV.var"#106#107"{Vector{UInt8}, Base.RefValue{Int64}, Int64, IOStream, Int64, CSV.Options{UInt8, UInt8, Nothing, Tuple{}, typeof(CSV._identity)}, UInt8, UInt8})(val::Float64, col::Int64, nm::Symbol)
    @ CSV ~/.julia/packages/CSV/jFiCn/src/write.jl:371
  [3] eachcolumn
    @ ~/.julia/packages/Tables/T7rHm/src/utils.jl:70 [inlined]
  [4] writerow(buf::Vector{UInt8}, pos::Base.RefValue{Int64}, len::Int64, io::IOStream, sch::Tables.Schema{(:Variable, :ARAG, :CALC, :pH, :H, :Hfree, :CO3, :fCO2, :RF, :DIC, :TA, :Temp, :Sal), Tuple{String, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64}}, row::DataFrameRow{DataFrame, DataFrames.Index}, cols::Int64, opts::CSV.Options{UInt8, UInt8, Nothing, Tuple{}, typeof(CSV._identity)})
    @ CSV ~/.julia/packages/CSV/jFiCn/src/write.jl:367
  [5] (::CSV.var"#99#100"{Bool, Bool, Tables.Schema{(:Variable, :ARAG, :CALC, :pH, :H, :Hfree, :CO3, :fCO2, :RF, :DIC, :TA, :Temp, :Sal), Tuple{String, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64}}, DataFrames.DataFrameRows{DataFrame}, CSV.Options{UInt8, UInt8, Nothing, Tuple{}, typeof(CSV._identity)}, Vector{UInt8}, Int64, Int64, NTuple{13, Symbol}})(io::IOStream)
    @ CSV ~/.julia/packages/CSV/jFiCn/src/write.jl:235
  [6] with(f::CSV.var"#99#100"{Bool, Bool, Tables.Schema{(:Variable, :ARAG, :CALC, :pH, :H, :Hfree, :CO3, :fCO2, :RF, :DIC, :TA, :Temp, :Sal), Tuple{String, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64}}, DataFrames.DataFrameRows{DataFrame}, CSV.Options{UInt8, UInt8, Nothing, Tuple{}, typeof(CSV._identity)}, Vector{UInt8}, Int64, Int64, NTuple{13, Symbol}}, io::Any, append::Bool, compress::Bool)
    @ CSV ~/.julia/packages/CSV/jFiCn/src/write.jl:303
  [7] #write#98
    @ ~/.julia/packages/CSV/jFiCn/src/write.jl:225 [inlined]
  [8] write(file::String, itr::DataFrame; delim::Char, quotechar::Char, openquotechar::Nothing, closequotechar::Nothing, escapechar::Char, newline::Char, decimal::Char, dateformat::Nothing, quotestrings::Bool, missingstring::String, transform::typeof(CSV._identity), bom::Bool, append::Bool, compress::Bool, writeheader::Nothing, partition::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ CSV ~/.julia/packages/CSV/jFiCn/src/write.jl:210
  [9] write(file::String, itr::DataFrame)
    @ CSV ~/.julia/packages/CSV/jFiCn/src/write.jl:171
 [10] top-level scope
    @ ~/Desktop/Julia_coding/A03_global_decadal/test.jl:85
in expression starting at /Users/Doe/Desktop/Julia_coding/A03_global_decadal/test.jl:85

Same here, have got the same problem.

1 Like

The current version of CSV is 0.10.9, not 0.10.4 - are you on some old Julia version (I think Julia 1.5 and earlier only support CSV up to 0.10.4)?

1 Like

Thanks for the info. I’m on Julia V1.7.2. Kind of reluctant to upgrade, because it will likely mess up my GMT.jl package.

Well then you might be out of luck, as clearly the current versions you have aren’t working. You can try to pin GMT in your environment and update (and undo if the update doesn’t go as planned), but I’m not sure why you would excpet GMT to be “messed up” by an update.

1 Like

Hey, found a better and fast solution.

“using DelimitedFiles\n”,
“\n”,
“open("sundial_3.txt", "w") do io\n”,
" writedlm(io, [time_3rd P_ex_1_3rd P_co_1_3rd P_res_1_3rd],‘,’)\n",
" end;"

time_3rd P_ex_1_3rd P_co_1_3rd P_res_1_3rd…they are vectors of length 5000. It created a text file with 4x5000 which is readable in Matlab, Excel and pyhton.

Cheers!

Sorry for the code, I use jupyter notebook on a Notepad++

After I upgrade my Julia to V1.8.5 and update the CSV package, this issue has been resolved. Many thanks.

1 Like

I got this error strangely between earlier this morning and later this morning. I updated everything (was in julia 1.8.1 → 1.8.5) CSV → 0.10.9, DataFrames → 1.3.6, Parsers → 2.5.8

Try the method I just mentioned.