Readtable with DataFrame v0.21.3

I need read a .txt file. The structure: red=DataFrames.readtable(“I:/Julia/CHO/cho1.txt”,allowcomments=true,separator=’ ')
worked with DataFrames v0.20.0 but not run with v0.21.3 (UndefVarError: readtable not defined)
How can I solve this problem?

See here:

Base.depwarn("readtable is deprecated, use CSV.read from the CSV package instead",
                 :readtable)

Although that deprecation message funnily is sort of deprecated itself, as CSV just deprecated CSV.read as of the latest v0.7.

So in short use DataFrame!(CSV.File(path))

3 Likes

Just because someone just liked the above post and I can’t edit it: my old post is deprecated, we’ve come full circle, these days do:

using CSV, DataFrames

CSV.read(path, DataFrame)
2 Likes

Thanks for the heads up. Why does the order of the file paths matter? In the case of single row and multiple row csv files

CSV.read([MultipleRowFile, SingleRowFile), DataFrame)

works but reversing the order of the files

CSV.read([SingleRowFile, MultipleRowFile), DataFrame)

returns the following error:

ERROR: UndefVarError: `A` not defined
Stacktrace:
 [1] (::CSV.var"#3#4")(x::PooledArrays.PooledVector{String31, UInt32, Vector{UInt32}})
   @ CSV ./none:0
 [2] iterate
   @ ./generator.jl:47 [inlined]
 [3] collect(itr::Base.Generator{Vector{PooledArrays.PooledVector{String31, UInt32, Vector{UInt32}}}, CSV.var"#3#4"})
   @ Base ./array.jl:834
 [4] chaincolumns!(a::Any, b::Any)
   @ CSV ~/.julia/packages/CSV/tmZyn/src/utils.jl:240
 [5] CSV.File(sources::Vector{String}; source::Nothing, kw::@Kwargs{})
   @ CSV ~/.julia/packages/CSV/tmZyn/src/file.jl:930
 [6] File
   @ ~/.julia/packages/CSV/tmZyn/src/file.jl:901 [inlined]
 [7] read(source::Vector{String}, sink::Type; copycols::Bool, kwargs::@Kwargs{})
   @ CSV ~/.julia/packages/CSV/tmZyn/src/CSV.jl:117
 [8] read(source::Vector{String}, sink::Type)
   @ CSV ~/.julia/packages/CSV/tmZyn/src/CSV.jl:113
 [9] top-level scope
   @ REPL[154]:1

I made a separate post but just wondering. Thanks!

Please start a separate thread with your question (as you have done already, and I have answered there)

1 Like